String offsets are full of oddities :

$str = "abc";
$str{0} = '';
var_dump($str); // -> string(3) "bc" (read as "\0bc")

Assigning an empty string to a string offset inserts a null byte because the string length is not checked in zend_assign_to_string_offset().

I see this as a bug. IMO, this case should raise a warning and the string should remain unchanged.

Thoughts before I register a bug and a PR ?

Regards

François

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to