View Full Version : $_ variables
Phantom
04-29-2003, 09:59 PM
$_COOKIES['var']
$_SESSION['var']
$_GET['var']
$_POST['var']
What's the difference between naming a var like that, and just using plain ol' $var?
scroots
04-29-2003, 10:16 PM
the underscore (_) is just somebodys preference. Some of those may be defined in the php manual that they have to be an underscore. If i write a script with my own varaibles i can call them what i like within certain limitations.
scroots
Phantom
04-29-2003, 10:22 PM
What I'm saying is the difference between "$var" and "$_COOKIES['var']"...
Jason
04-29-2003, 10:40 PM
$var is a user defined variable where as something like $_cookies('var') is a variable with the name var defined from cookies. I think thats how it can be read...
I know if you have a form and its a get/post if the user selects some check boxes or what not their values can be found by using $_GET('check_box_name') which returns an array...does that make sence?
Jason
mordred
04-30-2003, 12:35 PM
$_POST, $_GET et al are new so-called super-global variables available in PHP > 4.1. They contain the various values of variables that are available from a POST request etc., and they are arrays you use just in the same manner as the older $HTTP_POST_VARS arrays.
Super-global means that those $_ variables are visible in any scope. That means, you don't have to put a "global $_POST" inside your function any longer.
Currently those super-globals are the best way to deal with values passed through forms etc., because they are 1) super-global and 2) also available if the configuration setting register_globals is set to off - which is the standard setting for new PHP distributions.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.