0

I'm working through updating this PHP based website and I've noticed that there are a lot of these statements like

IF(foo['bar']){
    //Foo your Bars here
}

For this rudimentary example, my analysis indicated that the value stored at foo['bar'] is an integer.

I distinctly remember learning in school that value != 0 translates to TRUE when performing a boolean test - does this hold true in PHP as well?

Will
  • 3,413
  • 7
  • 50
  • 107
  • 2
    Did you test it? http://sandbox.onlinephpfunctions.com/code/1ca18f1fbe57194b8056e77cd930bac7c64dc5d0 – AbraCadaver Aug 24 '15 at 20:20
  • @AbraCadaver I did not. I was not aware that site exists. Thanks for the link. – Will Aug 24 '15 at 20:22
  • You could test it on your website. Also check http://php.net/manual/en/language.types.type-juggling.php – AbraCadaver Aug 24 '15 at 20:23
  • @AbraCadaver Thanks for the info. I tested and it turns out that VALUE != 0 is what always translates to true any non zero value is true, even in PHP. That's pretty nifty. Thanks. – Will Aug 24 '15 at 20:24

0 Answers0