PHP fmod() Function

In this chapter you will learn:

  1. Definition for PHP fmod() Function
  2. Syntax for PHP fmod() Function
  3. Parameter for PHP fmod() Function
  4. Return for PHP fmod() Function
  5. 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

ParameterIs Required Description
xRequired. 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:

  1. Definition for PHP getrandmax() Function
  2. Syntax for PHP getrandmax() Function
  3. Parameter for PHP getrandmax() Function
  4. Return for PHP getrandmax() Function
  5. Example - Return largest possible random value that can be returned by rand()