$a = 1;
$b = 2;
$c = 3;
$a && $b = $c;echo "a:$ a";
echo "b:$b";
echo "c:$c";
This is
a:1
b:3
c:3
$a = 0;
$b = 2;
$c = 3;
$a && $b = $c;echo "a:$a" ;
echo "b:$b";
echo "c:$c";
This is
a:0
b:2
c:3
Analysis:
1: The priority of && and the assignment operator "=" is && has a higher priority, but in the red writing method, $a and $b do not do the AND operation first and then =$c. This understanding is equivalent to 1= $c, and writing 1=$c is wrong
2: The correct way to understand this alternative writing method is:
if($a){$b = $c}, that is, if $a is true, the assignment statement $b = $c will be executed; otherwise, the assignment statement will not be executed, so the result is not difficult to understand