Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sqrt()

sqrt() is a PHP native function, that computes the square root of a number. That function takes a integer or a float, and returns the same types, depending on the actual value of the result.

sqrt() is not a particularly slow function. The opposite of sqrt() is ** 2, or pow($x, 2), or even $x * $x, where $x is the result of sqrt().

<?php

    $a = 4;
    var_dump(sqrt($a));
    
    $b = 5;
    var_dump(sqrt($b));

?>

Documentation

See Also