Ask a question about the if statement in a function. if a Cainiao has similar functions, it is incomplete. just give an example.
Function p_abc ($ a = '', $ B ='', $ c = ''){
$ A = xxx
If ($ B = '000000 '){
$ A = xxx + 1
}
$ C = yyy
}
When $ B = '000000', the function can run normally. when $ B is not equal to 255, it seems that $ c = yyy cannot be executed (I'm not sure ). Cause program errors.
Why? I am a newbie, please tell me.
Reply to discussion (solution)
One = is a value assignment.
Two = is a comparison
Your if ($ B = '000000') {is to make $ B 255, and the expression will always be true.
Should Write if ($ B = '000000 '){
If ($ B = '000000 ')
There is no problem with your delivery syntax, but this must be true. this is a value assignment.
Use = and = for equality in php
Example name result
$ A = $ B is equal to TRUE. if $ a is equal to $ B after type conversion.
$ A ===$ B all equal to TRUE, if $ a is equal to $ B, and their types are the same.
$! = $ B is not equal to TRUE. if $ a is not equal to $ B after type conversion.
$ A <> $ B is not equal to TRUE. if $ a is not equal to $ B after type conversion.
$! = $ B is not all TRUE, if $ a is not equal to $ B, or they are of different types.
$ A <$ B small and TRUE, if $ a is strictly less than $ B.
$ A> $ B is greater than TRUE if $ a is strictly greater than $ B.
$ A <= $ B is less than or equal to TRUE, if $ a is less than or equal to $ B.
$ A >=$ B is greater than or equal to TRUE if $ a is greater than or equal to $ B.
Reference: http://www.php.net/manual/zh/language.operators.comparison.php