PHP sqrt( ) Function Last Updated : 22 Jun, 2023 Comments Improve Suggest changes 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 sqrt( ) 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 PHP | strptime() Function The strptime() function is an inbuilt function in PHP which is used to parse a time / date generated with strftime() function. The date and format are sent as a parameter to the strptime() function and it returns an array on success or False on failure. The array returned by the strptime() function 2 min read PHP strval() Function The PHP strval() function converts a given variable to a string. It takes a scalar variable (like integers, floats, and booleans) and converts it to its string representation. For arrays, objects, and resources, it does not work and may produce unexpected results.Syntaxstrval( $variable ) Parameter: 3 min read PHP strlen() Function The strlen() is a built-in function in PHP which returns the length of a given string.It calculates the length of the string including all the whitespaces and special characters. Syntax:strlen($string);Parameters: This parameter represents the string whose length is needed to be returned. Return Val 1 min read PHP strrev() Function Reversing a string is one of the most basic string operations and is used very frequently by developers and programmers. PHP comes with a built-in function to reverse strings. The strrev() function is a built-in function in PHP and is used to reverse a string. This function does not make any change 2 min read Like