PHP intdiv() Function Last Updated : 22 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report intdiv stands for integer division. This function returns the integer quotient of the division of the given dividend and divisor. This function internally removes the remainder from the dividend to make it evenly divisible by the divisor and returns the quotient after division. Syntax: int intdiv($dividend, $divisor) Parameters: The function takes two parameters as follows: $dividend: This signed integer parameter refers to the number to be divided. $divisor: This signed integer parameter refers to the number to be used as the divisor. Return Type: This function returns the quotient calculated. Examples: Input : $dividend = 5, $divisor = 2 Output : 2 Input : $dividend = -11, $divisor = 2 Output : -5 Exception/Error:: The function raises exception in following cases: If we pass the divisor as 0, then the function raises DivisionByZeroError exception. If we pass PHP_INT_MIN as the dividend and -1 as the divisor, then an ArithmeticError exception is thrown. Below program illustrates the working of intdiv in PHP: PHP <?php // PHP code to illustrate the working // of intdiv() Functions $dividend = 19; $divisor = 3; echo intdiv($dividend, $divisor); ?> Output: 6 After Seeing so far many may think that this function is equivalent to floor($dividend/$divisor) but the example will elaborate the difference. PHP <?php // PHP code to differentiate between // intdiv() and floor() $dividend = -19; $divisor = 3; echo intdiv($dividend, $divisor) ."\n". floor($dividend/ $divisor); ?> Output: -6 -7 Important points to note: intdiv() Function returns the quotient of integer division. The function may raise exceptions thus the developer has to tackle edge cases. The function is not equivalent to the floor function applied to the float division or '/'. Reference: http://php.net/manual/en/function.intdiv.php Comment More infoAdvertise with us Next Article PHP intdiv() Function P PronabM Follow Improve Article Tags : Misc Web Technologies PHP PHP-math PHP-function +1 More Practice Tags : Misc Similar Reads PHP | opendir() Function The opendir() function in PHP is an inbuilt function which is used to open a directory handle. The path of the directory to be opened is sent as a parameter to the opendir() function and it returns a directory handle resource on success, or FALSE on failure. The opendir() function is used to open up 2 min read PHP octdec( ) Function In the earlier days of computing, octal numbers and the octal numbering system was very popular for counting inputs and outputs because as it works in counts of eight, inputs and outputs were in counts of eight, a byte at a time. Due to a wide usage of octal number system many times it happens that 2 min read PHP | getcwd( ) Function The getcwd() function in PHP is an inbuilt function which is used to return the current working directory. This function does not accepts any parameter and returns the current working directory on successful function call or FALSE on failure. Syntax: getcwd() Parameters: This function does not accep 2 min read PHP Math Functions PHP is a scripting language that comes with many built-in math functions and constants. These tools help you do basic math, solve more complex problems, and work with different math concepts. This guide gives an overview of PHP's math functions and constants, along with examples, practical uses, and 5 min read PHP | IntlChar::isdigit() Function The IntlChar::isdigit() function is an inbuilt function in PHP which is used to determine the given input code data is a digited character or not. It returns true when the character is under the general category decimal digit numbers. Beginning with Unicode 4, this is the same as testing for the Num 2 min read Like