intdiv():Integer division (quotient) of a number

<?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 )
ParameterDESCRIPTION
$dividendRequired : dividend of the division.
$divisiorRequired : Divisor of the division.
The output is integer quotient of the division.
Available in PHP 7 , PHP 8

Example: Handling Division by Zero

try {
    echo intdiv(10, 0);  // Will throw DivisionByZeroError
} catch (DivisionByZeroError $e) {
    echo "Cannot divide by zero!";
}

Example: Dividing Negative Numbers

echo intdiv(-10, 3);  // Output: -3

Example: Dividing Large Numbers

echo intdiv(1000000, 500);  // Output: 2000

Example: Using intdiv() with Mixed Positive and Negative Numbers

echo intdiv(15, -4);  // Output: -3

Example: Dividing Evenly Divisible Numbers

echo intdiv(20, 5);  // Output: 4
These examples show how `intdiv()` handles large numbers, mixed positive/negative values, and evenly divisible integers.
Math Functions fmod(): floating point remainder (modulo) of the division
base_convert(): Convert number From any base to other


Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer