O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.1. Common Math

The functions in this section offer most of the common mathematical operations that are part of arithmetic, geometry, and trigonometry. Most of these functions work on either doubles or integers. The return type will be the same as the argument. Unless a specific type is called for, I've written “number” to indicate that either an integer or a double is expected.

number abs(number value)

The abs function (Listing 13.1) returns the absolute value of a number. This is the number itself if it's positive or the number multiplied by negative one (–1) if negative.

Listing 13.1. abs
<?php
    //prints 13
    print(abs(-13));
?>

double acos(double value)

The acos function (Listing 13.2) returns the arc cosine of the value argument. Trying ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required