- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- 1 5 5 5 5 5
<?php
$a = 1;
$x = 2;
function test() {
global $a;
global $x;
$GLOBALS['a'] = &$x;
$x = 5;
echo $a . PHP_EOL;
echo $x . PHP_EOL;
}
test();
echo PHP_EOL;
echo $a . PHP_EOL; // $a is 1 here instead of 5
echo $x . PHP_EOL;
$a = &$x;
echo PHP_EOL;
echo $a . PHP_EOL;
echo $x . PHP_EOL;