find the square root of a number in php

To find the square root of a number in PHP, you can use the sqrt() function. This function takes a single parameter which is the number whose square root you want to find. Here's an example:

main.php
$number = 25;
$sqrt = sqrt($number);
echo "The square root of $number is $sqrt"; // Output: The square root of 25 is 5
119 chars
4 lines

In this example, we assign the value 25 to the $number variable. We then use the sqrt() function to find the square root of the number and assign the result to the $sqrt variable. Finally, we use an echo statement to print out the result.

You can use this function to find the square root of any positive number in PHP.

related categories

gistlibby LogSnag