mirror of
https://github.com/php/php-src.git
synced 2024-12-02 22:34:55 +08:00
bfe3f934a3
Convert the empty string assignment to an Error as per RFC [1] Add a warning that only the first byte will be assigned to the offset if provided a needle that is longer than one byte. [1] https://wiki.php.net/rfc/engine_warnings
35 lines
742 B
PHP
35 lines
742 B
PHP
--TEST--
|
|
Bug #71572: String offset assignment from an empty string inserts null byte
|
|
--FILE--
|
|
<?php
|
|
|
|
$str = "abc";
|
|
try {
|
|
var_dump($str[0] = "");
|
|
} catch (\Error $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
try {
|
|
var_dump($str[1] = "");
|
|
} catch (\Error $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
try {
|
|
var_dump($str[3] = "");
|
|
} catch (\Error $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
try {
|
|
var_dump($str[10] = "");
|
|
} catch (\Error $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
var_dump($str);
|
|
?>
|
|
--EXPECT--
|
|
Cannot assign an empty string to a string offset
|
|
Cannot assign an empty string to a string offset
|
|
Cannot assign an empty string to a string offset
|
|
Cannot assign an empty string to a string offset
|
|
string(3) "abc"
|