When I echo a PHP Boolean value in HTML, whether inside a tag or outside, the PHP code returned seems to be an empty string for false
and "1" for true
. This happens with the Boolean objects, and variables which return Boolean values, but not the strings "true" and "false". For example, in the following code,
<div id="<?php echo true; ?>"><?php echo true; ?></div>
<div id="<?php echo false; ?>"><?php echo false; ?></div>
the first div
will have an ID
of "true" and will have "true" as its text, while the second div
will have an ID
of "false" and will have "false" as its content. I have tested this in Google Chrome 34 and Firefox 29 Beta (IE11 won't load the page). I used Firebug, Google Chrome's Web Developer Tools, and Firebug Lite to see what the browser won't show. What's going on here?