Search code examples
phpglobal-variablessuperglobalsregister-globals

What exactly does it mean to "register" a variable


This is regarding the PHP global variables. Does it mean the global variables are simply assigned values through the HTTP request(ie: Varaibles where pre-existing but without values), or that the variables are "instantiated" and assigned values(ie: variable where not pre-existing in script)? I am yet to see any text which explains.


Solution

  • PHP's register_globals will create the appropriate global variables and assign values to them. Note that it's probably a really bad idea to use register_globals, since it poses a security risk. It's better to use the superglobal arrays $_POST, $_GET and $_COOKIE.