• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Are string values 0 and 1 in an array the same as true / false?

LPH

Well-known member
#1
This may seem like a silly question but something happened in the latest updates for WordPress and Redux Framework. For years, I've used $options['something'] == true and it stopped working. Now, the code must be $options['something'] == '1' in order to do as expected. A var_dump shows string instead of int and thus the question: are string values 0 and 1 in an array the same as true / false? I'm trying to figure out why the code is now failing when using true or false.
 

LPH

Well-known member
#3
It turns out the use of strict comparisons is the issue.

“1” == true [ Correct. ]
“1” === true [ Incorrect. ]

Even though my question showed loose, the code was using strict.