boolval 函数用于获取变量的布尔值。高佣联盟 www.cgewang.com
版本要求:PHP 5 >= 5.5.0, PHP 7。
语法
boolean boolval ( mixed $var )
参数说明:
实例
实例
<?php echo '0: '.(boolval(0) ? 'true' : 'false')."
"; echo '42: '.(boolval(42) ? 'true' : 'false')."
"; echo '0.0: '.(boolval(0.0) ? 'true' : 'false')."
"; echo '4.2: '.(boolval(4.2) ? 'true' : 'false')."
"; echo '"": '.(boolval("") ? 'true' : 'false')."
"; echo '"string": '.(boolval("string") ? 'true' : 'false')."
"; echo '"0": '.(boolval("0") ? 'true' : 'false')."
"; echo '"1": '.(boolval("1") ? 'true' : 'false')."
"; echo '[1, 2]: '.(boolval([1, 2]) ? 'true' : 'false')."
"; echo '