Google News
logo
PHP Program to Find the absolute (positive) value of a number
In PHP, you can find the absolute (positive) value of a number using the `abs()` function. Here's an example :
Program :
<?php
$number = -5;
$absolute = abs($number);

echo "The absolute value of $number is $absolute\n";
?>
Output :
The absolute value of -5 is 5
In this example, the variable `$number` is defined with the value `-5`. The `abs()` function is called with `$number` as an argument to find the absolute value of `-5`, and the result is stored in the variable `$absolute`.

The value of `$absolute` is then output using `echo`.