Home > Article > Backend Development > PHP commonly used functions-mathematics PHP commonly used string functions PHP commonly used class libraries PHP commonly used English singles
In the process of learning PHP, I compiled some commonly used functions. These are mathematical functions.
header("Content-Type:text/html;charset=UTF-8");
//Find the absolute value abs();
echo abs(-12)."
"; //12
//Rounding method
echo ceil(7.9999)."
"; //8
//Rounding method
echo floor(7.9999). "
"; //7
//Floating point number remainder
$x = 5.7;
$y = 1.3;
echo fmod($x,$y)."
" ; //0.5 1.3*4+0.5=5.7
/*
* $x = 3.6;
* $y = 0.6;
* echo $r = fmod($x,$y);
* If there is no remainder, it will appear Unpredictable results
*/
//Return the nth power of the number
echo pow(5,3)."
"; //125 5 raised to the third power is 125
//Floating point numbers are rounded
echo round(1.95583,2)."
"; //1.96
//Find the square root
echo sqrt(64)."
"; //8
//Find the maximum Value and minimum value (parameters cannot be variables)
echo max(1,3,5,7,9)."
"; //9
echo min(5,7,9)."< ;br/>"; //5
echo max(array(1,3,5,7,9))."
"; //9
echo min(array(3,5, 7,9))."
"; //3
//Random number
echo mt_rand(0,4)."
"; //Random
echo rand(5, 9)."
"; //Random
//Get pi
echo pi(); //3.1415926535898
The above has introduced the common functions of PHP - mathematics, including PHP, common aspects. I hope it will be helpful to friends who are interested in PHP tutorials.