note 11532 added to Variables from outside PHP

From: Date: Fri, 23 Feb 2001 16:03:24 +0000
Subject: note 11532 added to Variables from outside PHP
Groups: php.notes 
Request: Send a blank email to php-notes+get-11480@lists.php.net to get a copy of this message
If you want to have variables always globally registered, dependless on setting of register_globals you can call following code before your scripts (remember that track_vars must be on - which is the default in PHP4): if(!ini_get('register_globals')){ $__am = array('COOKIE','POST','GET'); while(list(,$__m) = each($__am)){ $__ah = &${"HTTP_".$__m."_VARS"}; if(!is_array($__ah)) continue; while(list($__n, $__v) = each ($__ah)) $$__n = $__v; } } You can easily change the order in which cookie, get and post variables are registered. Similar trick can be made for magic_quotes - in this way, you can make your scripts not being affected by the server settings. http://www.php.net/manual/en/language.variables.external.php

« previous php.notes (#11480) next »