Home > Article > Backend Development > PHP integer division calculation quotient
PHP's integer division operator (/) can be used to calculate the quotient of dividing two numbers and return a floating point number quotient. The specific syntax is: $quotient = $divisor / $divisor; if you need an integer quotient, you can use the intdiv() function.
PHP Integral division operation and quotient
Introduction
Integer division operation (%
) is used to calculate the remainder of dividing two numbers, but sometimes we want to get the quotient instead of the remainder. You can use the /
operator in PHP to get the quotient.
Syntax
$商 = $被除数 / $除数;
Among them:
$quotient
is the variable to store the quotient. $The dividend
is the number to be divided. $The divisor
is the number to be divided. Practical case
Calculate the quotient of dividing 12 by 5:
$商 = 12 / 5; echo $商; // 输出 2.4
Note:
/
The operator returns only floating point quotients. intdiv()
function. The above is the detailed content of PHP integer division calculation quotient. For more information, please follow other related articles on the PHP Chinese website!