PHP abs — absolute value

In PHP, abs returns the magnitude of a number. For example, the absolute value of −6 is 6, and the absolute value of 0 is 0.

A simple example

abs

  1. Start with −3
  2. Do this Measure distance from zero
  3. Result 3
From −3, three unit steps reach zero. The magnitude is 3.
lesson.php
<?php
echo (abs(-3)), PHP_EOL;
Output
3