Only First Byte

When assigning a string to a position inside another string, PHP reports a warning: indeed, only the first byte is used.

PHP code

<?php

$str = 'xy';

// first letter is now a
$str[0] = 'a';

// second letter is now b, c is ignored
$str[1] = 'bc';

echo $str;

?>

Before

ab

After

PHP Warning:  Only the first byte will be assigned to the string offset in /codes/onlyFirstByte.php on line 9

Warning: Only the first byte will be assigned to the string offset in /codes/onlyFirstByte.php on line 9
ab

PHP version change

This behavior changed in 8.0

Error Messages