PHP - Get bool to echo false when false

前端 未结 14 1874
予麋鹿
予麋鹿 2020-11-22 14:09

The following code doesn\'t print out anything:

$bool_val = (bool)false;
echo $bool_val;

But the following code prints 1:

14条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 14:53

    This is the easiest way to do this:

    $text = var_export($bool_value,true);
    echo $text;
    

    or

    var_export($bool_value)
    

    If the second argument is not true, it will output the result directly.

提交回复
热议问题