Sometimes, if (! AB) and if (! B) Actually, there is a difference. I used the previous method several times to get the desired result. I would like to ask the difference between the two. Supplement: Sorry, I wrote an error. It should be! B And! Is there any difference between AB? (Isn't it the same before, because... sometimes you will find if (! A = B) And if (! = B) actually there is a difference;
Several times I used the previous method to get the desired result. I would like to ask the difference between the two.
Supplement:
Sorry, I wrote an error.
It should be! = B and! Is there a difference between a = B?
(Was it because I wrote a mistake ?!)
Reply content:
Sometimes, if (! A = B) And if (! = B) actually there is a difference;
Several times I used the previous method to get the desired result. I would like to ask the difference between the two.
Supplement:
Sorry, I wrote an error.
It should be! = B and! Is there a difference between a = B?
(Was it because I wrote a mistake ?!)
The landlord wrote an error, right? Note:! $a == $b
, No! $a = $b
Although the PHP operator priority!
Priority higher=
But a strange syntax is! $a = $b
In this case$b
Assigned$a
, And then! $a
, Then this statement will always return$b == false
Same result. And$a != $b
It cannot be compared.
While! $a == $b
And$a != $b
Same...
In addition, according to my understanding! $a == $b
And$a != $b
The results are the same. I didn't think of a special case for the time being. However, many values in PHP can have the same meaning as Boolen. It is inevitable that some of the special situations you say occur during the conversion. List the situations where PHP and false are equivalent:
Boolean value FALSE
Integer value 0 (0)
Floating point value: 0.0 (0)
Empty string and string "0"
Array that does not contain any elements
Objects that do not include any member variables (applicable only to PHP 4.0)
Special Type NULL (including unassigned variables)
SimpleXML object generated from null tag
For example$a = 0
,$b = 1
, Then:
$a = $b
Yes 1 ,! 1 is false, so if (! $ A = $ B) is false
$a != $b
Yes 1! = 0 is obviously true
If (! $ A = $ B) is equivalent to if (! ($ A = $ B )).
By the way, which teacher taught you this writing?
A! = B
! A = B
An equal sign is being assigned a value.
Code style is very important
// A and B are strings, and the values of the two should be not equal. However, their corresponding boolean values are false $ a = '0'; $ B = ''; $! = $ B; // true! $ A = $ B; // false
The output result is as follows: