Guest User

DumpVariable

a guest
Sep 26th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. <?php
  2. $string = "Todor";
  3. $int = 4;
  4. $float = 3.14;
  5. $array = array("Red", "Blue", "Green");
  6. $object = (object)[4,23];
  7.  
  8. $variables = array($string, $int, $float, $array, $object);
  9.  
  10. foreach ($variables as $variable) {
  11.     checkVar($variable);
  12. }
  13.  
  14. function checkVar($variable) {
  15.     if (is_numeric($variable)) {
  16.         var_dump($variable);
  17.     }
  18.     else {
  19.         echo gettype($variable) . "<br/>";
  20.     }
  21. }
Add Comment
Please, Sign In to add comment