xref: /PHP-8.4/ext/standard/tests/array/bug31158.phpt (revision c322da06)
1--TEST--
2Bug #31158 (array_splice on $GLOBALS crashes)
3--INI--
4error_reporting = E_ALL
5--FILE--
6<?php
7function __(){
8  $GLOBALS['a'] = "bug\n";
9  array_splice($GLOBALS,0,count($GLOBALS));
10  /* All global variables including $GLOBALS are removed */
11  echo $GLOBALS['a'];
12}
13__();
14echo "ok\n";
15?>
16--EXPECTF--
17Fatal error: Uncaught Error: array_splice(): Argument #1 ($array) could not be passed by reference in %s:%d
18Stack trace:
19#0 %s(%d): __()
20#1 {main}
21  thrown in %s on line %d
22