Cast Precedence¶
<?php
$c = 100;
echo (int) $c * 0.12345;
?>
Casting has a higher precedence than multiplication (and addition). Here, the cast on the float happens first, which leads to 0. This 0 is later multiplied by 100, and that still gives 0.
If $c was the first operand, it would be cast first to integer, with no impact, and then multiplied: that leads to a float value, even with the cast.
See Also¶
Reverse illustration [Try me]
PHP Features¶
Last updated: 14 July 2026