This chapter describes the expressions for PHP.
The expression in PHP is no different from other languages. An ordinary assignment is an expression, a function is an expression, and a function is assigned a value. The ternary conditional operator is also, that is:
$first? $second: $third
There are many languages, no more speaking.
Finally, let's take an example from the PHP website:
1 2 function double ($i)
3 {
4 return $i * 2;
5}
6 $b = $a = 5; /* Assign the value five into the variable $a and $b */
7 $c = $a + +; /* Post-increment, assign original value of $a
8 (5) to $c */
9 $e = $d = + + $b; /* Pre-increment, assign the incremented value of
$b (6) to $d and $e */
11
*/* At the point, both $d and $e is equal to 6 */
13
$f = Double ($d + +); /* Assign twice the value of $d before
The increment, 2*6 = $f */
$g = double (+ + $e); /* Assign twice the value of $e after
Increment, 2*7 = $g */
$h = $g + = 10; /* First, $G is incremented by and ends with the
Value of 24. The value of the assignment () is
Assigned to $h, and $h ends with the value
as well. */
?>