1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/ext/standard/tests/array/bug31158.phpt
Nikita Popov 3c68f38fda Restrict allowed usages of $GLOBALS
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.
2021-01-06 12:46:24 +01:00

22 lines
476 B
PHP

--TEST--
Bug #31158 (array_splice on $GLOBALS crashes)
--INI--
error_reporting = E_ALL
--FILE--
<?php
function __(){
$GLOBALS['a'] = "bug\n";
array_splice($GLOBALS,0,count($GLOBALS));
/* All global variables including $GLOBALS are removed */
echo $GLOBALS['a'];
}
__();
echo "ok\n";
?>
--EXPECTF--
Fatal error: Uncaught Error: array_splice(): Argument #1 ($array) cannot be passed by reference in %s:%d
Stack trace:
#0 %s(%d): __()
#1 {main}
thrown in %s on line %d