锟斤拷锟斤拷锟斤拷锟斤拷燃锟�

锟斤拷锟斤拷锟斤拷锟斤拷燃锟街革拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷式锟襟定碉拷锟叫讹拷"锟斤拷锟斤拷"锟斤拷锟斤拷锟界,锟斤拷锟绞� 1 + 5 * 3 锟侥斤拷锟斤拷锟� 16 锟斤拷锟斤拷锟斤拷 18 锟斤拷锟斤拷为锟剿号o拷"*"锟斤拷锟斤拷锟斤拷锟饺硷拷锟饺加号o拷"+"锟斤拷锟竭★拷锟斤拷要时锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷强锟狡改憋拷锟斤拷锟饺硷拷锟斤拷锟斤拷锟界:(1 + 5) * 3 锟斤拷值为 18锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟饺硷拷锟斤拷同锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷慕锟较凤拷锟斤拷锟斤拷锟斤拷烁锟斤拷锟斤拷锟斤拷锟姐。锟斤拷锟界,"-"锟斤拷锟斤拷锟斤拷锟侥o拷锟斤拷么 1 - 2 - 3 锟酵碉拷同锟斤拷 (1 - 2) - 3 锟斤拷锟揭斤拷锟斤拷锟� -4. 锟斤拷锟斤拷一锟斤拷锟芥,"="锟斤拷锟斤拷锟斤拷锟侥o拷锟斤拷锟斤拷 $a = $b = $c 锟斤拷同锟斤拷 $a = ($b = $c)锟斤拷

没锟叫斤拷系锟斤拷锟酵拷锟斤拷燃锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷使锟矫o拷锟斤拷锟斤拷 1 < 2 > 1 锟斤拷PHP锟角诧拷锟较凤拷锟侥★拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷式 1 <= 1 == 1 锟角合凤拷锟斤拷, 锟斤拷为 == 锟斤拷锟斤拷锟饺硷拷锟斤拷锟斤拷 <=锟斤拷

锟斤拷锟脚碉拷使锟矫o拷锟斤拷锟斤拷锟节诧拷锟角憋拷要锟侥筹拷锟斤拷锟铰o拷通锟斤拷锟斤拷锟脚碉拷锟斤拷锟斤拷锟斤拷锟饺凤拷锟斤拷锟斤拷锟斤拷锟剿筹拷颍锟斤拷强锟斤拷锟斤拷锟斤拷锟斤拷锟饺硷拷锟酵斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟酵拷锟斤拷芄锟斤拷锟斤拷哟锟斤拷锟侥可讹拷锟皆★拷

锟铰憋拷锟斤拷锟斤拷锟饺硷拷锟接高碉拷锟斤拷锟叫筹拷锟斤拷锟斤拷锟斤拷锟斤拷锟酵伙拷锟斤拷械锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷同锟斤拷锟饺硷拷锟斤拷锟斤拷时锟斤拷锟角的斤拷戏锟斤拷锟斤拷锟斤拷锟斤拷值顺锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷燃锟�
锟斤拷戏锟斤拷锟� 锟斤拷锟斤拷锟� 锟斤拷锟斤拷锟斤拷息
锟斤拷 clone new clone 锟斤拷 new
锟斤拷 [ array()
锟斤拷 ** 锟斤拷锟斤拷锟斤拷锟斤拷锟�
锟斤拷 ++ -- ~ (int) (float) (string) (array) (object) (bool) @ 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷硷拷
锟斤拷 instanceof 锟斤拷锟斤拷
锟斤拷 ! 锟竭硷拷锟斤拷锟斤拷锟�
锟斤拷 * / % 锟斤拷锟斤拷锟斤拷锟斤拷锟�
锟斤拷 + - . 锟斤拷锟斤拷锟斤拷锟斤拷锟�锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟�
锟斤拷 << >> 位锟斤拷锟斤拷锟�
锟斤拷 < <= > >= 锟饺斤拷锟斤拷锟斤拷锟�
锟斤拷 == != === !== <> <=> 锟饺斤拷锟斤拷锟斤拷锟�
锟斤拷 & 位锟斤拷锟斤拷锟�锟斤拷锟斤拷锟斤拷
锟斤拷 ^ 位锟斤拷锟斤拷锟�
锟斤拷 | 位锟斤拷锟斤拷锟�
锟斤拷 && 锟竭硷拷锟斤拷锟斤拷锟�
锟斤拷 || 锟竭硷拷锟斤拷锟斤拷锟�
锟斤拷 ?? 锟饺斤拷锟斤拷锟斤拷锟�
锟斤拷 ? : ternary
right = += -= *= **= /= .= %= &= |= ^= <<= >>= 锟斤拷值锟斤拷锟斤拷锟�
锟斤拷 and 锟竭硷拷锟斤拷锟斤拷锟�
锟斤拷 xor 锟竭硷拷锟斤拷锟斤拷锟�
锟斤拷 or 锟竭硷拷锟斤拷锟斤拷锟�

Example #1 锟斤拷戏锟斤拷锟�

<?php
$a 
5// (3 * 3) % 5 = 4
// ternary operator associativity differs from C/C++
$a true true 2// (true ? 0 : true) ? 1 : 2 = 2

$a 1;
$b 2;
$a $b += 3// $a = ($b += 3) -> $a = 5, $b = 5
?>

Operator precedence and associativity only determine how expressions are grouped, they do not specify an order of evaluation. PHP does not (in the general case) specify in which order an expression is evaluated and code that assumes a specific order of evaluation should be avoided, because the behavior can change between versions of PHP or depending on the surrounding code.

Example #2 Undefined order of evaluation

<?php
$a 
1;
echo 
$a $a++; // may print either 2 or 3

$i 1;
$array[$i] = $i++; // may set either index 1 or 2
?>

Note:

锟斤拷锟斤拷 = 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟饺硷拷锟酵o拷PHP 锟皆撅拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟铰的憋拷锟绞斤拷锟�if (!$a = foo())锟斤拷锟节达拷锟斤拷锟斤拷 foo() 锟侥凤拷锟斤拷值锟斤拷锟斤拷锟斤拷锟斤拷 $a锟斤拷