is_bool()是php中的内置函数。is_bool()函数用于确定变量是否为布尔值。
null
语法 :
boolean is_bool($variable_name) $variable_name:the variable we want to check.
返回值 :这是一个布尔函数,因此当$variable_name是布尔值时返回TRUE,否则返回FALSE。
例1 :
<?php //php code $variable_name1 = false; $variable_name2 = 32; //$variable_name1 is boolean, gives TRUE if ( is_bool ( $variable_name1 )) echo "Variable is a boolean. " ; else echo 'Variable is not a boolean. ' ; //$variable_name2 is boolean, gives FALSE if ( is_bool ( $variable_name2 )) echo '32 is a boolean.' ; else echo '32 is not a boolean.' ; ?> |
输出 :
Variable is a boolean. 32 is not a boolean.
例2 :
<?php // PHP code function square( $num ) { return ( is_bool ( $num )); } echo square(TRUE) . "" ; // outputs '1'. echo square(FALSE) . "" ; // outputs '1'. echo square(56) . "" ; // nothing is returned. ?> |
输出 :
1 1
参考 : http://php.net/manual/en/function.is-bool.php
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END