Brackets and assignment inside of php's IF -


question:

code 1 , code 2 has got 1 difference - brackets.

i not why 1st causes error 2nd not.

code 1:

if (     $response = $myobject->response($request)     && $response2 = $myobject->response($response) // php notice: undefined variable: response  ) 

code 2:

if (     ($response = $myobject->response($request))     && $response2 = $myobject->response($response) // ok ) 

&& operator has higher precedence = operator.

the brackets change order of evaluation desire, expressions in brackets evaluated first(as in math).


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -