CKTIS / PHP
Quotient (/)
Divide the total cost by the number of units to get a unit price.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$value / $operandDivide the total cost by the number of units to get a unit price. Operand order determines the unit of the result.
A zero divisor raises DivisionByZeroError. Exact division of two integers yields an integer, while a fractional result has type float. Overflow is an exception. Evaluating PHP_INT_MIN / -1 produces a float.
Evaluation
16 / 4→49 / 2→4.5(-3) / 2→-1.5
Examples
<?php
echo json_encode(16 / 4), PHP_EOL;
echo json_encode(9 / 2), PHP_EOL;
echo json_encode((-3) / 2), PHP_EOL;
Result
4 4.5 -1.5