1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function double($i)
{
return $i2;
}
$b = $a = 5; / assign the value five into the variable $a and $b /
$c = $a++; / postincrement, assign original value of $a
(5) to $c /
$e = $d = ++$b; / preincrement, assign the incremented value of
$b (6) to $d and $e /
/ at this point, both $d and $e are equal to 6 /
$f = double($d++); / assign twice the value of $d before
the increment, 26 = 12 to $f /
$g = double(++$e); / assign twice the value of $e after
the increment, 27 = 14 to $g /
$h = $g += 10; / first, $g is incremented by 10 and ends with the
value of 24. the value of the assignment (24) is
then assigned into $h, and $h ends with the value
of 24 as well. /
?>
一些表达式可以被当成语句。这时,一条语句的形式是 expr ;,即一个表达式加一个分号结尾。在 '$b = $a = 5;' 中,'$a = 5' 是一个有效的表达式,但它本身不是一条语句。而 '$b = $a = 5;' 则是一条有效的语句。