- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>PHP Get Absolute Value of a Number</title>
- </head>
- <body>
- <?php
- echo abs(5) . "<br>"; // 0utputs: 5 (integer)
- echo abs(-5) . "<br>"; // 0utputs: 5 (integer)
- echo abs(4.2) . "<br>"; // 0utputs: 4.2 (double/float)
- echo abs(-4.2) . "<br>"; // 0utputs: 4.2 (double/float)
- ?>
- </body>
- </html>