&& depends of the evaluation of the right expression when left one is true, || doesn't. You could rewrite it to:
if(
$users == 'all' ||
($_POST['user'] == 1 && $users == 'admins') ||
($_POST['user'] == 0 && $users == 'mods')
)
And it'll be the same.
Answer from Ben on Stack OverflowVideos
&& depends of the evaluation of the right expression when left one is true, || doesn't. You could rewrite it to:
if(
$users == 'all' ||
($_POST['user'] == 1 && $users == 'admins') ||
($_POST['user'] == 0 && $users == 'mods')
)
And it'll be the same.
With no parenthesis, PHP will evaluate each expression from left to right, using PHP's operator precedence along the way. However, as in any logical check, throwing AND into the mix can make things confusing and a lot harder to read.
The result is correct. PHP will perform the multiplication first and then the addition. It looks like this:
$res = 225 + (154 * 256) + (138 * 256 * 256) + (81 * 256 * 256 * 256)
$res = 225 + 39424 + 9043968 + 1358954496
$res = 1368038113
225 + 154 * 256 + 138 * 256 * 256 + 81 * 256 * 256 * 256
=>
225
+
154 * 256 = 39,424
+
138 * 256 * 256 = 9,043,968
+
81 * 256 * 256 * 256 = 1,358,954,496
=>
225 + 39,424 + 9,043,968 + 1,358,954,496
=>
225
+
39,424
+
9,043,968
+
1,358,954,496
=>
1,368,038,113
EDIT
Why do I think you're doing:
225 + 154 * 256 + 138 * 256 * 256 + 81 * 256 * 256 * 256
=>
225 + 154 = 379
*
256 = 97,024
+
138 = 97,162
*
256 = 24,873,472
*
256 = 6,367,608,832
+
81 = 6,367,608,913
*
256 = 1,630,107,881,728
*
256 = 417,307,617,722,368
*
256 = 106,830,750,136,926,208
As your link https://www.php.net/manual/en/language.operators.precedence.php already explains, the table is ordered by precedence.
First, you've got in line 3 the type cast (https://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting), than the 6th line (arithmetic operators).
Your code is equivalent to
Copy$x = ((float)'100') / 100;
or
Copy$y = (float)'100';
$x = $y / 100;
respectively.
According to the table you linked to, type casting has higher precedence (row 3) than multiplication and division operators (row 6). So it's treated as
Copy$x = ((float)'100') / 100;
It first casts '100' to float, then performs the division.