intdiv

(PHP 7)

intdiv�Գ������ȡ��

˵��

intdiv ( int $dividend , int $divisor ) : int

���� dividend ���� divisor �������������֡�

����

dividend

��������

divisor

������

����ֵ

dividend ���� divisor ���̣��Ը���ȡ����

�����쳣

��� divisor �� 0�����׳� DivisionByZeroError �쳣�� ��� dividend �� PHP_INT_MIN ���� divisor �� -1�����׳� ArithmeticError �쳣.

����

Example #1 intdiv() ��һЩ����

<?php
var_dump
(intdiv(32));
var_dump(intdiv(-32));
var_dump(intdiv(3, -2));
var_dump(intdiv(-3, -2));
var_dump(intdiv(PHP_INT_MAXPHP_INT_MAX));
var_dump(intdiv(PHP_INT_MINPHP_INT_MIN));
var_dump(intdiv(PHP_INT_MIN, -1));
var_dump(intdiv(10));
?>
int(1)
int(-1)
int(-1)
int(1)
int(1)
int(1)

Fatal error: Uncaught ArithmeticError: Division of PHP_INT_MIN by -1 is not an integer in %s on line 8
Fatal error: Uncaught DivisionByZeroError: Division by zero in %s on line 9