mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
3c68f38fda
This restricts allowed usage of $GLOBALS, with the effect that plain PHP arrays can no longer contain INDIRECT elements. RFC: https://wiki.php.net/rfc/restrict_globals_usage Closes GH-6487.
47 lines
728 B
PHP
47 lines
728 B
PHP
--TEST--
|
|
Converting undefined index/offset notice to exception
|
|
--FILE--
|
|
<?php
|
|
|
|
set_error_handler(function($_, $msg) {
|
|
throw new Exception($msg);
|
|
});
|
|
|
|
$test = [];
|
|
try {
|
|
$test[0] .= "xyz";
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
var_dump($test);
|
|
|
|
try {
|
|
$test["key"] .= "xyz";
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
var_dump($test);
|
|
|
|
unset($test);
|
|
try {
|
|
$GLOBALS["test"] .= "xyz";
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
var_dump($test);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Undefined array key 0
|
|
array(0) {
|
|
}
|
|
Undefined array key "key"
|
|
array(0) {
|
|
}
|
|
Undefined global variable $test
|
|
Undefined variable $test
|