note 16974 deleted from language.variables.predefined by jimw

From: Date: Fri, 14 Dec 2001 19:13:18 +0000
Subject: note 16974 deleted from language.variables.predefined by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22620@lists.php.net to get a copy of this message
Using the register_globals function of PHP can be dangerous, but it is handy in some situations. You can however use this function (maybe with a little more functionality, this was all I needed) to make sure hacking doesn't occur, but you can use 1 line in your code to get either an environment, post, get or cookie variable. <? /* This function is safe, since it FIRST returns * any environment variables, making sure they * can't be overwritten! * Cookies are done last, since they are more * to hacking. */ function get_var($var) { global $HTTP_ENV_VARS; global $HTTP_POST_VARS; global $HTTP_GET_VARS; global $HTTP_COOKIE_VARS; if(trim($HTTP_ENV_VARS["$var"]) != "") return $HTTP_ENV_VARS["$var"]; if(trim($HTTP_POST_VARS["$var"]) != "") return $HTTP_POST_VARS["$var"]; if(trim($HTTP_GET_VARS["$var"]) != "") return $HTTP_GET_VARS["$var"]; if(trim($HTTP_COOKIE_VARS["$var"]) != "") return $HTTP_COOKIE_VARS["$var"]; } ?> Hope you find this useful, Jesse Meijers

« previous php.notes (#22620) next »