+ 1

why (!null) is true?

if(!null) echo "true"; else echo "false"; //output : true

30th May 2017, 2:47 PM
kaushal singh
kaushal singh - avatar
3 Antworten
+ 21
Default boolean value of null is false and ! converts it to true
30th May 2017, 2:49 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 4
Think of ! as "is not", it helps (that's how CoffeeScript works too, and I love it). So, this: if(!null) Means: if is not null
30th May 2017, 4:02 PM
Taija
Taija - avatar
+ 2
thanks.
30th May 2017, 2:50 PM
kaushal singh
kaushal singh - avatar