note 65562 deleted from language.variables.predefined by bjori
| From: | bjori@php.net | Date: | Wed, 03 May 2006 15:05:49 +0000 |
| Subject: | note 65562 deleted from language.variables.predefined by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110453@lists.php.net to get a copy of this message | ||
Note Submitter: shylauda69 at yahoo dot com
Reason: bad code
----
if some developers still insist in supporting php versions of <4.1, you can use this for
getting/setting superglobal variables.
<?php
function getG ( $var ) {
global $HTTP_GET_VARS;
if ( isset ( $_GET[$var] ) ) {
return $_GET[$var];
}
elseif ( isset ( $_GET[$var] ) ) {
return $HTTP_GET_VARS[$var];
}
else {
return FALSE;
}
}
?>
the same thing for POST, ENV, SERVER, COOKIES..
thus you dont need to call the created "superglobals" (by $_GET &= $HTTP_GET_VARS)
using "global" keyword in every function that uses them and you can even perform any
appropriate actions on the variable before its returned.