Does a string of 'false' evaluate to Boolean in PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Does a string of 'false' evaluate to Boolean in PHP?

I think I've seen a couple of challenge questions about this whose answers I thought were inconsistent. Just trying to find out from any PHP pros.

20th Aug 2018, 12:38 AM
Sonic
Sonic - avatar
3 Answers
+ 4
Thanks Lexus Collins for the explanation code. I left a small question there for you in the comments.
20th Aug 2018, 6:17 AM
Sonic
Sonic - avatar
+ 3
Every string with something inside returns true and empty string returns false.
11th Dec 2018, 4:24 PM
Ferry
Ferry - avatar
+ 2
Any value enclosed in double or single quotes is seen as a string value, so 'false' will not evaluate to Boolean unless you manually convert it to a Boolean.
21st Aug 2018, 8:50 PM
Heinrich Käsner
Heinrich Käsner - avatar