3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Testing Globals $GLOBALS['A'] = 'B'; $arrayCopyGlobalsVar = $GLOBALS; $arrayCopyGlobalsVar['A'] = 'C'; var_dump([ '$GLOBALS' => $GLOBALS['A'], '$arrayCopyGlobalsVar' => $arrayCopyGlobalsVar['A'], ]); $GLOBALS['A'] = 'B'; $nonReferencedGlobalsVar = new ArrayObject($GLOBALS); $nonReferencedGlobalsVar = $nonReferencedGlobalsVar->getArrayCopy(); $nonReferencedGlobalsVar['A'] = 'D'; var_dump([ '$GLOBALS' => $GLOBALS['A'], '$nonReferencedGlobalsVar' => $nonReferencedGlobalsVar['A'] ]);

preferences:
23.07 ms | 404 KiB | 5 Q