Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a PHP script DumpVariable.php that declares a variable. If the variable is numeric, print it by
- the built-in function var_dump(). If the variable is not numeric, print its type at the input. */
- <?php
- function dumpVariable($var) {
- if (is_numeric($var)) {
- var_dump($var);
- } else {
- echo gettype($var)."\n";
- }
- }
- dumpVariable('hello');
- dumpVariable(15);
- dumpVariable(1.234);
- dumpVariable(array(1,2,3));
- dumpVariable((object)[2,34]);
- dumpVariable(false);
- dumpVariable('true');
- ?>
Add Comment
Please, Sign In to add comment