Differences

This shows you the differences between two versions of the page.

Link to this comparison view

computers:php_register_globals [2015/03/24 05:42] (current)
Line 1: Line 1:
 +====== PHP Register Globals ======
 +May be security risk or mess up your code
  
 +http://​us3.php.net/​manual/​en/​security.globals.php
 +
 +If register globals is on/off, you can change it by adding to apache .htaccess file:
 +
 +''​php_flag register_globals off''​
 +
 +OR
 +
 +''​php_flag register_globals on''​
 +
 +OR php code.
 +
 +<code php>
 +if (ini_get(register_globals)) { // if on, turn off
 +    $rg = array_keys($_REQUEST);​
 +    foreach($rg as $var)
 +    {
 +        if ($_REQUEST[$var] === $$var)
 +        {
 +            unset($$var);​
 +        }
 +    }
 +}
 +
 +</​code>​
 +
 +<code php>
 +if (! ini_get(register_globals)) { // if off, turn on
 +    extract($_REQUEST,​ EXTR_OVERWRITE); ​
 +   //If variable of same name exits, this will overwrite it;
 +}
 +
 +</​code>​
 +
 +You cannot set register_globals using http://​www.php.net/​ini_set.