Skip to content
Advertisement

PHP – Get bool to echo false when false

The following code doesn’t print out anything:

JavaScript

But the following code prints 1:

JavaScript

Is there a better way to print 0 or false when $bool_val is false than adding an if statement?

Advertisement

Answer

JavaScript

Or if you only want output when it’s false:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement