PHP bool casts


Casting various values to bool in PHP, the results are sometimes surprising.

(I know the exports are wrong here, that's part of why I submitted this. testing the boolean column type)

License CC0
Created 7 months ago
Updated 7 months ago
Revisions 4 (see changes)
Visits 140  
Column toggles, sort, filtering … coming soon
Export presets:

Note: In the X Macro option, add &noq=foo,bar to the URL to strip quotes from specified columns

Input Boolean value Note
'' false
'[]' true !
[] false
0 false
'0' false
'0.0' true WRONG
0.0 false
1 true
-1 true
'1' true
'1.0' true
1.0 true
false false
'false' true !
NULL false
(object)[] true WRONG
true true
'true' true