if 判断为 false 的 6 种情况
if判断为false的6种情况
class TestController extends Controller
{
function actionIndex()
{
$temp = '';//空字符串
$this->test_false($temp);
$temp = '0';//字符串0
$this->test_false($temp);
$temp = 0;//整型0
$this->test_false($temp);
$temp = 0.00;//浮点型0
$this->test_false($temp);
$temp = [];//浮点型0
$this->test_false($temp);
$temp = null;//浮点型0
$this->test_false($temp);
exit();
}
function test_false($data)
{
if ($data){
p('true');
}else{
p('false');
}
}
}
输出结果:
false
false
false
false
false
false
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: