I've seen both of them.
Reply content:
There's no difference in efficiency.
--------------
if (1== $user)
In programming, if you forget a =, the program will error
if ($user ==1)
If you forget a =, you may never find it.
is to use programming habits to reduce the code of the error, reduce the accidental bug I have to manually test the verification under:
in pursuit of performance to this point, you have to change the language it! In a dynamic language like PHP, how does it hurt to compare this efficiency problem? The efficiency of considering this situation is meaningless thanks to the invitation! Although no such tests have been done, there should be no difference in efficiency. Appreciate this attitude of the landlord. $ time php test.phpreal 0m12.352suser 0m0.000ssys 0m0.015s$ time PHP test1.phpreal 0m12.240suser 0m0.000ssys 0m0.031s$ time php test2.phpreal 0m4.635suser 0m0.015ssys 0m0.0 00s$ time PHP test3.phpreal 0m4.620suser 0m0.000ssys 0m0.015s
It's hard to see the difference in efficiency. The main purpose of this writing is to avoid the = =, after all, when the dizzy eye looks like a $ A = 1 is very similar to the right, and 1 = $a no matter how dizzy you are or will feel wrong.
In addition to this habit exists not only in the writing of PHP, in other languages is also very common this does not involve the efficiency problem, this is a code habit, in order to prevent hand errors, will be written = =, this error is all C and C derivative language or C language programmers have made mistakes ~ ~