A "heterogeneous" syntax in PHP: $a && $b = $c;
$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
Analytical:
1: The && and assignment operator "=" has a priority of && precedence, but the accents is not written in $a and $b first and then = $c, so understanding is equivalent to 1= $c, and 1= $c such a notation is wrong
2: This kind of alternative writing is correctly understood in the following way:
if ($a) {$b = $c}, that is, if $ A is true, execute the assignment statement $b = $c; otherwise this assignment statement is not executed, so the result is not difficult to understand
The above describes a "heterogeneous" syntax in PHP: $a && $b = $c, including aspects of the content, want to be interested in PHP tutorial friends helpful.