codegurukool.com · Free coding tutorials & online compiler

Home › PHP Tutorial › PHP numbers and math

PHP numbers and math

Calculate with built-in math functions.

Use max, round, sqrt, pow and intdiv for everyday maths. The % operator gives the remainder.

Example code

<?php
echo max(3, 9, 5) . PHP_EOL;
echo round(3.14159, 2) . PHP_EOL;
echo sqrt(81) . PHP_EOL;
echo pow(2, 10) . PHP_EOL;
echo intdiv(17, 5) . PHP_EOL;
echo (17 % 5) . PHP_EOL;
?>

Run this code in the online editor

← PHP stringsPHP if...else...elseif →