PHP 8 Beginner Basics · 1 min read

PHP math helpers

Start the PHP 8 learning path »

❮ PHP 8 Home All Tutorials ❯

How do I do min/max/round/random in PHP?

Built-in math functions.

Example

PHP 8 Example
<?php
echo min(3, 8, 1);
echo max(3, 8, 1);
echo abs(-12);
echo sqrt(49);
echo round(4.6);
echo rand(1, 10);

Line-by-Line Walkthrough

is_int / is_float / is_numeric help validate numbers.

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…