Example:
x = 24 - 20 / 4
For that, 24/4 will be done first, then the result of the division will become the reduction of 24 so that yields 19 non 1. That thing is caused by the priority of operator/higher than operator -.
The table of operator priority:
| Priority | Operators | Workmanship sequence |
| 1 | new | non-associative |
| 2 | [ | right |
| 3 | ! ~ ++ -- (int) (float) (string) (array) (object) @ |
right |
| 4 | * / % |
left |
| 5 | + - . |
left |
| 6 | << >> |
left |
| 7 | < <= > >= |
non-associative |
| 8 | == != === !== |
non-associative |
| 9 | & | left |
| 10 | ^ | left |
| 11 | | | left |
| 12 | && | left |
| 13 | || | left |
| 14 | ?: | left |
| 15 | = += -= *= /= .= %= &= |=^= <<= >>= |
left |
| 16 | right | |
| 17 | and | left |
| 18 | xor | left |
| 19 | or | left |
| 20 | , | left |
Operator in the same line have the same priority.
Pay attention to the example of using string operator at script as following:
File name: operatorpriority.php
<html>
<head>
<title>Operator Priority</title>
</head>
<body>
<pre>
$a = 25;
$b = 10;
$c = 15;
$result = $a + $b * $c / 3;
</pre>
<h3>Processed by PHP</h3>
<?
$a = 25;
$b = 10;
$c = 15;
$result = $a + $b * $c / 3;
echo ("Result = $result");
?>
</body>
</html>