note 115434 added to reserved.variables.globals

From: Date: Wed, 23 Jul 2014 05:18:49 +0000
Subject: note 115434 added to reserved.variables.globals
Groups: php.notes 
Request: Send a blank email to php-notes+get-200032@lists.php.net to get a copy of this message
Here's how to get a copy of the $GLOBALS array without running into recursion or including local environment variables. <?php foreach( $GLOBALS as $k => $v ){ if( $k != 'GLOBALS' && !ctype_lower($k) ){ $a[$k] = $v; } } extract($a); // (or $my_globals = var_export($a,true)) ?> Using extract() makes $FOO equivalent to $GLOBALS['FOO'], so you can use shorthand like with constants, for brevity and string literals (like "$FOO bar" versus "{$GLOBALS['FOO']} bar"). ---- Server IP: 72.52.91.14 Probable Submitter: 71.220.116.206 ---- Manual Page -- http://php.net/manual/en/reserved.variables.globals.php Edit -- https://master.php.net/note/edit/115434 Del: integrated -- https://master.php.net/note/delete/115434/integrated Del: useless -- https://master.php.net/note/delete/115434/useless Del: bad code -- https://master.php.net/note/delete/115434/bad+code Del: spam -- https://master.php.net/note/delete/115434/spam Del: non-english -- https://master.php.net/note/delete/115434/non-english Del: in docs -- https://master.php.net/note/delete/115434/in+docs Del: other reasons-- https://master.php.net/note/delete/115434 Reject -- https://master.php.net/note/reject/115434 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200032) next »