PHP sqrt( ) Function Last Updated : 22 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report Many times it happens that while solving mathematical expressions we require to calculate the square root of a number. To solve this issue like other programming language PHP provides us with a built-in function sqrt() which can be used to calculate the square root of a number. The sqrt() function in PHP is used to calculate the square root of a number. We already have discussed about sqrt() function in brief in the article PHP | Math functions. In this article we will learn about the sqrt() function in details. Syntax: float sqrt(value) Parameters: This function accepts a single parameter $value. It is the number whose square root you want to know. Return Value: It returns a floating-point value which is the square root of the argument $value passed to it. Examples: Input : sqrt(25) Output : 5 Input : sqrt(-25) Output : NaN Input : sqrt(0.09) Output :0.3 Input : sqrt(0) Output : 0 Below programs illustrate the working of sqrt() in PHP: When a positive number is passed as a parameter: PHP <?php echo(sqrt(25)); ?> Output: 5 When a negative number is passed as a parameter: PHP <?php echo(sqrt(-25)); ?> Output: NaN When a number with decimal places is passed as a parameter: PHP <?php echo(sqrt(0.09)); ?> Output: 0.3 When zero is passed as a parameter: PHP <?php echo(sqrt(0)); ?> Output: 0 Important Points To Note: sqrt() function is used to calculate the square root of a number.It is much more efficient than the generic method of square root calculation.Precision depends on the user's precision directive. Reference: http://php.net/manual/en/function.sqrt.php Comment More infoAdvertise with us Next Article PHP rtrim() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-math PHP-function +1 More Practice Tags : Misc Similar Reads PHP strtr() Function The strtr() is an inbuilt function in PHP which is used to replace a substring in a string to a given string of characters. It also has the option to change a particular word to a different word in a string. The function is case sensitive. Syntax: strtr($string, $string1, $string2) or, strtr($string 4 min read PHP | gmp_sqrt() Function The gmp_sqrt() is a built-in function in PHP which is used to calculate the square root of a GMP number (GNU Multiple Precision : For large numbers). This function returns only the integral part of the square root of the GMP number. Syntax: gmp_sqrt ( $num ) Parameters: This function accepts a GMP n 2 min read PHP strstr() Function The strstr() function is a built-in function in PHP. It searches for the first occurrence of a string inside another string and displays the portion of the latter starting from the first occurrence of the former in the latter (before if specified). This function is case-sensitive. Syntax : strstr( $ 2 min read PHP | stat( ) function The stat() function in PHP is an inbuilt function which is used to return information of a file. The stat(0) function returns statistics of a file which is an array with the following elements : [0] or [dev] - Device number [1] or [ino] - Inode number [2] or [mode] - Inode protection mode [3] or [nl 4 min read PHP rtrim() Function The rtrim() function is a built-in function in PHP which removes whitespaces or other characters (if specified) from the right side of a string. Syntax:rtrim( $string, $charlist )Parameters: The function rtrim() accepts two parameters as shown in the above syntax. Out of these two parameters, one is 2 min read PHP stristr() Function The stristr() function is a built-in function in PHP. It searches for the first occurrence of a string inside another string and displays the portion of the latter starting from the first occurrence of the former in the latter (before if specified). This function is case-insensitive. Syntax : strist 2 min read Like