note 69337 added to function.get-defined-vars

From: Date: Fri, 01 Sep 2006 02:32:55 +0000
Subject: note 69337 added to function.get-defined-vars
Groups: php.notes 
Request: Send a blank email to php-notes+get-116577@lists.php.net to get a copy of this message
A little gotcha to watch out for: If you turn off RegisterGlobals and related, then use get_defined_vars(), you may see something like the following: <?php Array ( [GLOBALS] => Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array() [_GET] => Array() [_COOKIE] => Array() [_FILES] => Array() ) [_POST] => Array() [_GET] => Array() [_COOKIE] => Array() [_FILES] => Array() ) ?> Notice that $_SERVER isn't there. It seems that php only loads the superglobal $_SERVER if it is used somewhere. You could do this: <?php print '<pre>' . htmlspecialchars(print_r(get_defined_vars(), true)) . '</pre>'; print '<pre>' . htmlspecialchars(print_r($_SERVER, true)) . '</pre>'; ?> And then $_SERVER will appear in both lists. I guess it's not really a gotcha, because nothing bad will happen either way, but it's an interesting curiosity nonetheless. ---- Server IP: 216.194.113.175 Probable Submitter: 24.216.237.243 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.get-defined-vars.php Edit -- https://master.php.net/note/edit/69337 Del: integrated -- https://master.php.net/note/delete/69337/integrated Del: useless -- https://master.php.net/note/delete/69337/useless Del: bad code -- https://master.php.net/note/delete/69337/bad+code Del: spam -- https://master.php.net/note/delete/69337/spam Del: non-english -- https://master.php.net/note/delete/69337/non-english Del: in docs -- https://master.php.net/note/delete/69337/in+docs Del: other reasons-- https://master.php.net/note/delete/69337 Reject -- https://master.php.net/note/reject/69337 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116577) next »