The sqrt Function

The sqrt function finds the square root of a number.

Syntax

phpsqrt(number);

Example

Let's calculate the square root of 16:

php<?php
  echo sqrt(16);
?>

Code execution result:

php4

Example

Let's calculate the square root of 5:

php<?php
  echo sqrt(5);
?>

Code execution result:

php2.2360679774998

See Also

  • the pow function,
    which raises a number to a power
  • the lesson exponentiation,
    which explains the ** operator
  • the round function,
    which rounds a number according to mathematical rules