Backend Development 2 min read

PHP fmod() Function – Returns Floating‑Point Remainder of Division

This article explains PHP's fmod() function, detailing its syntax, parameter meanings, return value, and provides a practical code example that demonstrates how it calculates the floating‑point remainder of a division operation.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP fmod() Function – Returns Floating‑Point Remainder of Division

The article describes the PHP fmod() function, which returns the floating‑point remainder of dividing one number by another.

Syntax

float fmod ( float $x, float $y )

Parameters

$x – the dividend.

$y – the divisor (must be non‑zero).

Return value

The function returns the remainder r such that x = i * y + r , where i is an integer; the sign of r matches the sign of x and its absolute value is less than y .

Example

The output comment shows that $r equals 0.5 , confirming the function’s behavior.

BackendPHPmath functionfloating-point remainderfmod
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.