当前位置:Gxlcms > PHP教程 > php变量类型判断的例子

php变量类型判断的例子

时间:2021-07-01 10:21:17 帮助过:23人阅读

  1. $s = "this is a string";
  2. $i = 9;
  3. $arr = array(2,4,6);
  4. is_string($s); //返回TRUE,表示$s是一个字符串变量
  5. is_string($i); //返回FALSE,表示$i不是一个字符串变量
  6. is_array($arr); //返回TRUE,表示$arr是一个数组
  7. is_array($s); //返回FALSE,表示$s不是一个数组
  8. $str = "this is a string";
  9. $int = 9;
  10. $bool = FALSE;
  11. echo "\$str的类型是:".gettype($str);
  12. echo "
    ";
  13. echo "
    ";
  14. echo "\$int的类型是:".gettype($int);
  15. echo "
    ";
  16. echo "
    ";
  17. echo "\$bool的类型是:".gettype($bool);
  18. ?>

人气教程排行