Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

array_sum() Checks Operands Thoroughly

array_sum() used to cast the arguments to integers before executing the additions. Nowadays, the strange types raise a warning, as illustrated here with the array.

PHP code

<?php

print array_sum([1, false, []]);

?>

Before

1

After

PHP Warning:  array_sum(): Addition is not supported on type array

Warning: array_sum(): Addition is not supported on type array
1

PHP version change

This behavior changed in 8.3.

See Also

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat