Error in PHP with bool arithmetic in loops -


It seems that there is an error in Boolean arithmetic loops in PHP.

In this particular example I test if all the important form fields (represented by the object) were set. var_dump is for debugging purposes.

  $ allset = true; Forex Currency ($ form as $ form): $ allset = $ one- & gt; Thats () and $ allset; Endforeach; Var_dump ($ allset); Foreign Currency ($ $ as $ more): $ allset = $ one- & gt; Thats () and $ allset; Endforeach; Var_dump ($ allset); $ Allset = $ iwasthere-> Thats () and $ allset; Var_dump ($ allset);   

This code may fail, it is possible that the first dump returns false and the second return is correct.

My question

How can I save this error and I have a small and clean code?


PS

I now use the if block. The problem here is that = is operated by and

operator, so assignment expression is just part of a logical expression and the whole expression is equivalent to:
  ($ allset = $ one-> Thats ()) and $ Allset;   

Either put a logical expression in parentheses or use and instead of and :

 < Code> $ allset = ($ one-> Thats () and $ AllSet); $ Allset = $ one- & gt; Thats () & amp; Amp; $ Allset;    

Comments