<?Php
echo intdiv(4,9); // Output 0
echo "<br>";
echo intdiv(3,5); // Output 0
echo "<br>";
echo intdiv(20,10); // Output is 2
echo "<br>";
echo intdiv(2,13); // Output is 0
echo "<br>";
echo intdiv(4,100); // Output is 0
echo "<br>";
echo intdiv(100,4); // Output is 25
?>
Syntax
int intdiv ( int $dividend , int $divisor )
Parameter | DESCRIPTION |
---|---|
$dividend | Required : dividend of the division. |
$divisior | Required : Divisor of the division. |
try {
echo intdiv(10, 0); // Will throw DivisionByZeroError
} catch (DivisionByZeroError $e) {
echo "Cannot divide by zero!";
}
echo intdiv(-10, 3); // Output: -3
echo intdiv(1000000, 500); // Output: 2000
echo intdiv(15, -4); // Output: -3
echo intdiv(20, 5); // Output: 4
These examples show how `intdiv()` handles large numbers, mixed positive/negative values, and evenly divisible integers.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.