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

range() With Int And String

range() now emits a warning when one of the arguments is a string, and the other is an integer. It still behaves like before, and cast the string to an integer.

PHP code

<?php

print_r(range(1, 'z')); 

?>

Before

Array
(
    [0] => 1
    [1] => 0
)

After

PHP Warning:  range(): Argument #1 ($start) must be a single byte string if argument #2 ($end) is a single byte string, argument #2 ($end) converted to 0 

Warning: range(): Argument #1 ($start) must be a single byte string if argument #2 ($end) is a single byte string, argument #2 ($end) converted to 0 
Array
(
    [0] => 1
    [1] => 0
)

PHP version change

This behavior changed in 8.3.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat