@@ -101,6 +101,9 @@ primary-expression:
101101 object-creation-expression
102102 postfix-increment-expression
103103 postfix-decrement-expression
104+ prefix-increment-expression
105+ prefix-decrement-expression
106+ shell-command-expression
104107 '(' expression ')'
105108-->
106109
@@ -116,6 +119,9 @@ primary-expression:
116119 <i ><a href =" #grammar-object-creation-expression " >object-creation-expression</a ></i >
117120 <i ><a href =" #grammar-postfix-increment-expression " >postfix-increment-expression</a ></i >
118121 <i ><a href =" #grammar-postfix-decrement-expression " >postfix-decrement-expression</a ></i >
122+ <i ><a href =" #grammar-prefix-increment-expression " >prefix-increment-expression</a ></i >
123+ <i ><a href =" #grammar-prefix-decrement-expression " >prefix-decrement-expression</a ></i >
124+ <i ><a href =" #grammar-shell-command-expression " >shell-command-expression</a ></i >
119125 ( <i ><a href =" #grammar-expression " >expression</a ></i > )
120126</pre >
121127
@@ -1494,9 +1500,10 @@ class Point
14941500 public function __toString()
14951501 {
14961502 return '(' . $this->x . ',' . $this->y . ')';
1497- } // get private properties $x and $y
1498- public function __set($name, $value) { ... }
1499- public function __get($name) { ... }
1503+ }
1504+ // get private properties $x and $y
1505+ public function __set($name, $value) { ... }
1506+ public function __get($name) { ... }
15001507}
15011508$p1 = new Point;
15021509$p1->move(3, 9); // calls public instance method move by name
@@ -1584,6 +1591,158 @@ $i = 10; $j = $i-- + 100; // old value of $i (10) is added to 100
15841591$a = array(100, 200); $v = $a[1]++; // old value of $ia[1] (200) is assigned
15851592```
15861593
1594+ ### Prefix Increment and Decrement Operators
1595+
1596+ ** Syntax**
1597+
1598+ <!-- GRAMMAR
1599+ prefix-increment-expression:
1600+ '++' variable
1601+
1602+ prefix-decrement-expression:
1603+ '--' variable
1604+ -->
1605+
1606+ <pre >
1607+ <i id =" grammar-prefix-increment-expression " >prefix-increment-expression:</i >
1608+ ++ <i ><a href =" #grammar-variable " >variable</a ></i >
1609+
1610+ <i id =" grammar-prefix-decrement-expression " >prefix-decrement-expression:</i >
1611+ -- <i ><a href =" #grammar-variable " >variable</a ></i >
1612+ </pre >
1613+
1614+ ** Constraints**
1615+
1616+ The operand of the prefix ` ++ ` or ` -- ` operator must be a modifiable lvalue
1617+ that has scalar-compatible type.
1618+
1619+ ** Semantics**
1620+
1621+ * Arithmetic Operands*
1622+
1623+ For a prefix ` ++ ` operator used with an arithmetic operand, the [ side
1624+ effect] ( #general ) of the operator is to increment the value of the operand by 1.
1625+ The result is the value of the operand after it
1626+ has been incremented. If an ` int ` operand's value is the largest
1627+ representable for that type, the operand is incremented as if it were ` float ` .
1628+
1629+ For a prefix ` -- ` operator used with an arithmetic operand, the side
1630+ effect of the operator is to decrement the value of the operand by 1.
1631+ The result is the value of the operand after it has been
1632+ decremented. If an ` int ` operand's value is the smallest representable for
1633+ that type, the operand is decremented as if it were ` float ` .
1634+
1635+ For a prefix ` ++ ` or ` -- ` operator used with an operand having the value
1636+ ` INF ` , ` -INF ` , or ` NAN ` , there is no side effect, and the result is the
1637+ operand's value.
1638+
1639+ * Boolean Operands*
1640+
1641+ For a prefix ` ++ ` or ` -- ` operator used with a Boolean-valued operand, there
1642+ is no side effect, and the result is the operand's value.
1643+
1644+ * NULL-valued Operands*
1645+
1646+ For a prefix -- operator used with a ` NULL ` -valued operand, there is no
1647+ side effect, and the result is the operand's value. For a prefix ` ++ `
1648+ operator used with a ` NULL ` -valued operand, the side effect is that the
1649+ operand's type is changed to int, the operand's value is set to zero,
1650+ and that value is incremented by 1. The result is the value of the
1651+ operand after it has been incremented.
1652+
1653+ * String Operands*
1654+
1655+ For a prefix ` -- ` operator used with an operand whose value is an empty
1656+ string, the side effect is that the operand's type is changed to ` int ` ,
1657+ the operand's value is set to zero, and that value is decremented by 1.
1658+ The result is the value of the operand after it has been incremented.
1659+
1660+ For a prefix ` ++ ` operator used with an operand whose value is an empty
1661+ string, the side effect is that the operand's value is changed to the
1662+ string "1". The type of the operand is unchanged. The result is the new
1663+ value of the operand.
1664+
1665+ For a prefix ` -- ` or ` ++ ` operator used with a numeric string, the numeric
1666+ string is treated as the corresponding ` int ` or ` float ` value.
1667+
1668+ For a prefix ` -- ` operator used with a non-numeric string-valued operand,
1669+ there is no side effect, and the result is the operand's value.
1670+
1671+ For a non-numeric string-valued operand that contains only alphanumeric
1672+ characters, for a prefix ` ++ ` operator, the operand is considered to be a
1673+ representation of a base-36 number (i.e., with digits 0–9 followed by A–Z or a–z) in
1674+ which letter case is ignored for value purposes. The right-most digit is
1675+ incremented by 1. For the digits 0–8, that means going to 1–9. For the
1676+ letters "A"–"Y" (or "a"–"y"), that means going to "B"–"Z" (or "b"–"z").
1677+ For the digit 9, the digit becomes 0, and the carry is added to the next
1678+ left-most digit, and so on. For the digit "Z" (or "z"), the resulting
1679+ string has an extra digit "A" (or "a") appended. For example, when
1680+ incrementing, "a" -> "b", "Z" -> "AA", "AA" -> "AB", "F29" -> "F30", "FZ9" -> "GA0", and "ZZ9" -> "AAA0". A digit position containing a number wraps
1681+ modulo-10, while a digit position containing a letter wraps modulo-26.
1682+
1683+ For a non-numeric string-valued operand that contains any
1684+ non-alphanumeric characters, for a prefix ` ++ ` operator, all characters up
1685+ to and including the right-most non-alphanumeric character is passed
1686+ through to the resulting string, unchanged. Characters to the right of
1687+ that right-most non-alphanumeric character are treated like a
1688+ non-numeric string-valued operand that contains only alphanumeric
1689+ characters, except that the resulting string will not be extended.
1690+ Instead, a digit position containing a number wraps modulo-10, while a
1691+ digit position containing a letter wraps modulo-26.
1692+
1693+ * Object Operands*
1694+
1695+ If the operand has an object type supporting the operation,
1696+ then the object semantics defines the result. Otherwise, the operation has
1697+ no effect and the result is the operand.
1698+
1699+ ** Examples**
1700+
1701+ ``` PHP
1702+ $i = 10; $j = --$i + 100; // new value of $i (9) is added to 100
1703+ $a = array(100, 200); $v = ++$a[1]; // new value of $a[1] (201) is assigned
1704+ $a = "^^Z"; ++$a; // $a is now "^^A"
1705+ $a = "^^Z^^"; ++$a; // $a is now "^^Z^^"
1706+ ```
1707+
1708+ ### Shell Command Operator
1709+
1710+ ** Syntax**
1711+
1712+ <!-- GRAMMAR
1713+ shell-command-expression:
1714+ '`' dq-char-sequence? '`'
1715+ -->
1716+
1717+ <pre >
1718+ <i id =" grammar-shell-command-expression " >shell-command-expression:</i >
1719+ ` <i ><a href =" 09-lexical-structure.md#grammar-dq-char-sequence " >dq-char-sequence</a ></i ><sub >opt</sub > `
1720+ </pre >
1721+
1722+ where \` is the GRAVE ACCENT character U+0060, commonly referred to as a
1723+ * backtick* .
1724+
1725+ ** Semantics**
1726+
1727+ This operator passes * dq-char-sequence* to the command shell for
1728+ execution, as though it was being passed to the library function
1729+ [ ` shell_exec ` ] ( http://www.php.net/shell_exec ) . If the output from execution of that command is
1730+ written to [ ` STDOUT ` ] ( 06-constants.md#core-predefined-constants ) , that output is the result of this operator
1731+ as a string. If the output is redirected away from ` STDOUT ` , or
1732+ * dq-char-sequence* is empty or contains only white space, the result of
1733+ the operator is ` NULL ` .
1734+
1735+ If [ ` shell_exec ` ] ( http://php.net/manual/function.shell-exec.php ) is disabled, this operator is disabled.
1736+
1737+ ** Examples**
1738+
1739+ ``` PHP
1740+ $result = `ls`; // result is the output of command ls
1741+ $result = `ls >dirlist.txt`; // result is NULL
1742+ $d = "dir"; $f = "*.*";
1743+ $result = `$d {$f}`; // result is the output of command dir *.*
1744+ ```
1745+
15871746### Scope-Resolution Operator
15881747
15891748** Syntax**
@@ -1832,142 +1991,23 @@ for each.
18321991<!-- GRAMMAR
18331992unary-expression:
18341993 exponentiation-expression
1835- prefix-increment-expression
1836- prefix-decrement-expression
18371994 unary-op-expression
18381995 error-control-expression
1839- shell-command-expression
18401996 cast-expression
18411997-->
18421998
18431999<pre >
18442000<i id =" grammar-unary-expression " >unary-expression:</i >
18452001 <i ><a href =" #grammar-exponentiation-expression " >exponentiation-expression</a ></i >
1846- <i ><a href =" #grammar-prefix-increment-expression " >prefix-increment-expression</a ></i >
1847- <i ><a href =" #grammar-prefix-decrement-expression " >prefix-decrement-expression</a ></i >
18482002 <i ><a href =" #grammar-unary-op-expression " >unary-op-expression</a ></i >
18492003 <i ><a href =" #grammar-error-control-expression " >error-control-expression</a ></i >
1850- <i ><a href =" #grammar-shell-command-expression " >shell-command-expression</a ></i >
18512004 <i ><a href =" #grammar-cast-expression " >cast-expression</a ></i >
18522005</pre >
18532006
18542007** Semantics**
18552008
18562009These operators associate right-to-left.
18572010
1858- ### Prefix Increment and Decrement Operators
1859-
1860- ** Syntax**
1861-
1862- <!-- GRAMMAR
1863- prefix-increment-expression:
1864- '++' variable
1865-
1866- prefix-decrement-expression:
1867- '--' variable
1868- -->
1869-
1870- <pre >
1871- <i id =" grammar-prefix-increment-expression " >prefix-increment-expression:</i >
1872- ++ <i ><a href =" #grammar-variable " >variable</a ></i >
1873-
1874- <i id =" grammar-prefix-decrement-expression " >prefix-decrement-expression:</i >
1875- -- <i ><a href =" #grammar-variable " >variable</a ></i >
1876- </pre >
1877-
1878- ** Constraints**
1879-
1880- The operand of the prefix ` ++ ` or ` -- ` operator must be a modifiable lvalue
1881- that has scalar-compatible type.
1882-
1883- ** Semantics**
1884-
1885- * Arithmetic Operands*
1886-
1887- For a prefix ` ++ ` operator used with an arithmetic operand, the [ side
1888- effect] ( #general ) of the operator is to increment the value of the operand by 1.
1889- The result is the value of the operand after it
1890- has been incremented. If an ` int ` operand's value is the largest
1891- representable for that type, the operand is incremented as if it were ` float ` .
1892-
1893- For a prefix ` -- ` operator used with an arithmetic operand, the side
1894- effect of the operator is to decrement the value of the operand by 1.
1895- The result is the value of the operand after it has been
1896- decremented. If an ` int ` operand's value is the smallest representable for
1897- that type, the operand is decremented as if it were ` float ` .
1898-
1899- For a prefix ` ++ ` or ` -- ` operator used with an operand having the value
1900- ` INF ` , ` -INF ` , or ` NAN ` , there is no side effect, and the result is the
1901- operand's value.
1902-
1903- * Boolean Operands*
1904-
1905- For a prefix ` ++ ` or ` -- ` operator used with a Boolean-valued operand, there
1906- is no side effect, and the result is the operand's value.
1907-
1908- * NULL-valued Operands*
1909-
1910- For a prefix -- operator used with a ` NULL ` -valued operand, there is no
1911- side effect, and the result is the operand's value. For a prefix ` ++ `
1912- operator used with a ` NULL ` -valued operand, the side effect is that the
1913- operand's type is changed to int, the operand's value is set to zero,
1914- and that value is incremented by 1. The result is the value of the
1915- operand after it has been incremented.
1916-
1917- * String Operands*
1918-
1919- For a prefix ` -- ` operator used with an operand whose value is an empty
1920- string, the side effect is that the operand's type is changed to ` int ` ,
1921- the operand's value is set to zero, and that value is decremented by 1.
1922- The result is the value of the operand after it has been incremented.
1923-
1924- For a prefix ` ++ ` operator used with an operand whose value is an empty
1925- string, the side effect is that the operand's value is changed to the
1926- string "1". The type of the operand is unchanged. The result is the new
1927- value of the operand.
1928-
1929- For a prefix ` -- ` or ` ++ ` operator used with a numeric string, the numeric
1930- string is treated as the corresponding ` int ` or ` float ` value.
1931-
1932- For a prefix ` -- ` operator used with a non-numeric string-valued operand,
1933- there is no side effect, and the result is the operand's value.
1934-
1935- For a non-numeric string-valued operand that contains only alphanumeric
1936- characters, for a prefix ` ++ ` operator, the operand is considered to be a
1937- representation of a base-36 number (i.e., with digits 0–9 followed by A–Z or a–z) in
1938- which letter case is ignored for value purposes. The right-most digit is
1939- incremented by 1. For the digits 0–8, that means going to 1–9. For the
1940- letters "A"–"Y" (or "a"–"y"), that means going to "B"–"Z" (or "b"–"z").
1941- For the digit 9, the digit becomes 0, and the carry is added to the next
1942- left-most digit, and so on. For the digit "Z" (or "z"), the resulting
1943- string has an extra digit "A" (or "a") appended. For example, when
1944- incrementing, "a" -> "b", "Z" -> "AA", "AA" -> "AB", "F29" -> "F30", "FZ9" -> "GA0", and "ZZ9" -> "AAA0". A digit position containing a number wraps
1945- modulo-10, while a digit position containing a letter wraps modulo-26.
1946-
1947- For a non-numeric string-valued operand that contains any
1948- non-alphanumeric characters, for a prefix ` ++ ` operator, all characters up
1949- to and including the right-most non-alphanumeric character is passed
1950- through to the resulting string, unchanged. Characters to the right of
1951- that right-most non-alphanumeric character are treated like a
1952- non-numeric string-valued operand that contains only alphanumeric
1953- characters, except that the resulting string will not be extended.
1954- Instead, a digit position containing a number wraps modulo-10, while a
1955- digit position containing a letter wraps modulo-26.
1956-
1957- * Object Operands*
1958-
1959- If the operand has an object type supporting the operation,
1960- then the object semantics defines the result. Otherwise, the operation has
1961- no effect and the result is the operand.
1962-
1963- ** Examples**
1964-
1965- ``` PHP
1966- $i = 10; $j = --$i + 100; // new value of $i (9) is added to 100
1967- $a = array(100, 200); $v = ++$a[1]; // new value of $a[1] (201) is assigned
1968- $a = "^^Z"; ++$a; // $a is now "^^A"
1969- $a = "^^Z^^"; ++$a; // $a is now "^^Z^^"
1970- ```
19712011
19722012### Unary Arithmetic Operators
19732013
@@ -2115,44 +2155,6 @@ if ($curER === 0) error_reporting($origER);
21152155$x = $tmp;
21162156```
21172157
2118- ### Shell Command Operator
2119-
2120- ** Syntax**
2121-
2122- <!-- GRAMMAR
2123- shell-command-expression:
2124- '`' dq-char-sequence? '`'
2125- -->
2126-
2127- <pre >
2128- <i id =" grammar-shell-command-expression " >shell-command-expression:</i >
2129- ` <i ><a href =" 09-lexical-structure.md#grammar-dq-char-sequence " >dq-char-sequence</a ></i ><sub >opt</sub > `
2130- </pre >
2131-
2132- where \` is the GRAVE ACCENT character U+0060, commonly referred to as a
2133- * backtick* .
2134-
2135- ** Semantics**
2136-
2137- This operator passes * dq-char-sequence* to the command shell for
2138- execution, as though it was being passed to the library function
2139- [ ` shell_exec ` ] ( http://www.php.net/shell_exec ) . If the output from execution of that command is
2140- written to [ ` STDOUT ` ] ( 06-constants.md#core-predefined-constants ) , that output is the result of this operator
2141- as a string. If the output is redirected away from ` STDOUT ` , or
2142- * dq-char-sequence* is empty or contains only white space, the result of
2143- the operator is ` NULL ` .
2144-
2145- If [ ` shell_exec ` ] ( http://php.net/manual/function.shell-exec.php ) is disabled, this operator is disabled.
2146-
2147- ** Examples**
2148-
2149- ``` PHP
2150- $result = `ls`; // result is the output of command ls
2151- $result = `ls >dirlist.txt`; // result is NULL
2152- $d = "dir"; $f = "*.*";
2153- $result = `$d {$f}`; // result is the output of command dir *.*
2154- ```
2155-
21562158### Cast Operator
21572159
21582160** Syntax**
0 commit comments