PHP fmod() Function
In this chapter you will learn:
- Definition for PHP fmod() Function
- Syntax for PHP fmod() Function
- Parameter for PHP fmod() Function
- Return for PHP fmod() Function
- Example - Return the remainder of x/y
Definition
The fmod() function returns the remainder (modulo) of x/y.
Syntax
PHP fmod() Function has the following syntax.
fmod(x,y);
Parameter
Parameter | Is Required | Description |
---|---|---|
x | Required. | Dividend |
y | Required. | Divisor |
Return
Item | Description |
---|---|
Return Value | The floating point remainder of x/y |
Return Type | Float |
Example
Return the remainder of x/y:
<?php/*from j a v a2 s.co m*/
$x = 7;
$y = 2;
$result = fmod($x,$y);
echo $result;
?>
$result equals 1, because 2 * 3 + 1 = 7
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP getrandmax() Function
- Syntax for PHP getrandmax() Function
- Parameter for PHP getrandmax() Function
- Return for PHP getrandmax() Function
- Example - Return largest possible random value that can be returned by rand()
Home » PHP Tutorial » PHP Math Functions