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

Description

When range() produces all the values between two boundaries. These two boundaries must be of the same type, for consistency purpose. Hence, when one is a string, the second one also needs to be a string, and range() will generate all the values between these strings.

Example

<?php

range(1, 'b');

?>

Literal Examples

  • 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

Solutions

  • Cast the integer to a string.

  • Cast the string to an integer.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See rangeSingleByteString.