PHP abs() Function Last Updated : 29 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The abs() function is an inbuilt function in PHP which is used to return the absolute (positive) value of a number. The abs() function in PHP is identical to what we call modulus in mathematics. The modulus or absolute value of a negative number is positive. Syntaxnumber abs( value )ParametersThe abs() function accepts single parameter value which holds the number whose absolute value you want to find. Return ValueIt returns the absolute value of the number passed to it as argument. ExamplesInput : abs(6) Output : 6 Input : abs(-6) Output : 6 Input : abs(6.4) Output : 6.4 Input : abs(-6.4) Output : 6.4Below programs illustrate the abs() function in PHP: Program 1: When a positive number is passed as a parameter: PHP <?php echo (abs(6)); ?> Output6Program 2: When a negative number is passed as a parameter: PHP <?php echo (abs(-6)); ?> Output6Program 3: When a positive number with decimal places is passed as a parameter: PHP <?php echo (abs(6.4)); ?> Output6.4Program 4: When a negative number with decimal places is passed as a parameter: PHP <?php echo (abs(-6.4)); ?> Output6.4 Comment More infoAdvertise with us Next Article PHP abs() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-math PHP-function +1 More Practice Tags : Misc Similar Reads PHP cos( ) Function Trigonometry is an important part of mathematics and PHPâs math functions provides us with some functions which are very useful for calculations involving trigonometry. The cos()function in PHP is used to find the cosine of a number. The cos() function returns a float value between -1 and 1, which r 2 min read PHP eval() Function PHP eval() function in PHP is an inbuilt function that evaluates a string as PHP code. Syntax: eval( $string ) Parameters: This function accepts a single parameter as shown in the above syntax and described below. $string: It must consist of a valid PHP code to be evaluated but should not contain op 2 min read PHP each() Function The each() function is an inbuilt function in PHP and is used to get the current element key-value pair of the given array to which the internal pointer is currently pointing. After returning the key and value of the current element the internal pointer is incremented by one in the array. Note: You 2 min read PHP | Functions A function in PHP is a self-contained block of code that performs a specific task. It can accept inputs (parameters), execute a set of statements, and optionally return a value. PHP functions allow code reusability by encapsulating a block of code to perform specific tasks.Functions can accept param 8 min read PHP array() Function The array() function is an inbuilt function in PHP which is used to create an array. There are three types of array in PHP: Indexed array: The array which contains numeric index. Syntax: array( val1, val2, val3, ... ) Associative array: The array which contains name as keys. Syntax: array( key=>v 2 min read Like