PHP fmod()函数
PHP fmod()函数是一个数学函数,用于返回参数除法的浮点余数。
语法
float fmod ( float x , floaty );
Parameter | Description | Required/Optional |
---|---|---|
X | Specifiy the dividend | Required |
Y | Specify the divisor | Required |
示例1
<?php
x = 7;y = 2;
echo "Your Given Nos is : x=7,y=2"
result ="By using 'fmod()' Function your value is:".fmod(x,y);
echoresult;
// $result equals 1, because 2 * 3 + 1 = 7
?>
输出:
By using 'fmod()' Function your value is:1
示例2
<?php
x = 5.7;y = 1.3;
echo "Your Given Nos is : x=5.7, y=1.3";
echo "<br>"."By using 'fmod()' function your value is:".fmod(x,y);
// $r equals 0.5, because 4 * 1.3 + 0.5 = 5.7
?>
输出:
Your Given Nos is : x=5.7, y=1.3
By using 'fmod()' Function your value is:0.5