Page 1 of 1

adding a new key,value pair to the $_SERVER global array

Posted: Fri Sep 28, 2007 9:41 pm
by mechamecha
Hello,
Is it possible to add a new key-value pair to the $_SERVER superglobal array?

For example, when portions of facebook's code was leaked, there were many include clauses containing $_SERVER['PHP_ROOT']. I am guessing that $_SERVER['PHP_ROOT'] is storing the path to where all of the source code is kept, a path which is not accessible to an outsider.

I want to do the same, but I haven't found any resources that explain how this is done. Is modifying the $_SERVER array done by changing the configuration on the server app, such as appache?

Or perhaps there is a better approach to storing the path to a directory outside of the public one?

THanks

Posted: Sat Sep 29, 2007 1:22 am
by jeffery
If you have Apache module mod_env (environment) turned on, in an .htaccess file you can do this:

Code: Select all

SetEnv PHP_ROOT "/usr/share/application/"

Posted: Sat Sep 29, 2007 8:44 am
by feyd
The following works.

Code: Select all

$_SERVER['floob'] = 'party time';