Originally published on zero2php.dev — part of the Zero to PHP course. View this lesson on the original site.
Beyond arithmetic operators
Beyond + - * / **, PHP provides math functions—see Math.
Example
<?php
declare(strict_types=1);
echo abs(-5), "\n";
echo max(1, 7, 3), "\n";
echo round(1.2345, 2), "\n";
Clarity
Use parentheses when combining calls so you are explicit about order of operations.
Exercise
echo the largest value among 4, 9, and 2 using max(...) (single digit 9).
From Zero to PHP — PHP foundations: environment, syntax, and values