Home >Backend Development >PHP Tutorial >Example of php variable type judgment

Example of php variable type judgment

WBOY
WBOYOriginal
2016-07-25 09:04:51931browse
  1. $s = "this is a string";
  2. $i = 9;
  3. $arr = array(2,4,6);
  4. is_string($s); //return TRUE , indicating that $s is a string variable
  5. is_string($i); //Returns FALSE, indicating that $i is not a string variable
  6. is_array($arr); //Returns TRUE, indicating that $arr is an array
  7. is_array( $s); //Return FALSE, indicating that $s is not an array
  8. $str = "this is a string";
  9. $int = 9;
  10. $bool = FALSE;
  11. echo "The type of $str is:".gettype ($str);
  12. echo "
    ";
  13. echo "
    ";
  14. echo "The type of $int is: ".gettype($int);
  15. echo "
    ";
  16. echo "
    ";
  17. echo "The type of $bool is: ".gettype($bool);
  18. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn