Arithmetic ( + - * / % ** )
Try it yourself →Four operations, remainder (%), and exponentiation (**).
Syntax
$a + $b, $a % $b, $a ** $b
Description
Standard mathematical operators. % gives the remainder, ** gives the exponent.
Example
<?php echo 7 + 3; echo "\n"; echo 7 % 2; echo "\n"; echo 2 ** 10;
Expected output
10 1 1024
When to use?
Calculations, even/odd check (% 2).