开发者

Printing booleans in php

开发者 https://www.devze.com 2023-01-25 05:24 出处:网络
Is there something ready开发者_如何学运维 for printing Booleans in PHP (usually for debug), rather than writing: echo ($flag ? \"true\" : \"false\") every time?var_export($flag);

Is there something ready开发者_如何学运维 for printing Booleans in PHP (usually for debug), rather than writing: echo ($flag ? "true" : "false") every time?


var_export($flag);


$a = TRUE;
var_dump($a); // bool(true)


http://php.net/manual/en/language.types.string.php

A boolean TRUE value is converted to the string "1". Boolean FALSE is converted to "" (the empty string).

Your current method is probably the easiest method without calling a function.


You could write a little function - that would save chars and typing!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号