boolean - PHP - Get bool to echo false when false -
for reason, following code doesn't print out anything:
$bool_val = (bool)false; echo $bool_val;
but following code prints out 1:
$bool_val = (bool)true; echo $bool_val;
is there better way print out 0 or false when $bool_val false adding if statement?
edit: changed second statement false true
echo $bool_val ? 'true' : 'false';
or if want output when it's false:
echo !$bool_val ? 'false' : '';
Comments
Post a Comment