Page 1 of 1

Values missing values in $_server array

Posted: Sun May 02, 2010 3:44 am
by ankgne
I am using IIS as my web server and i am trying to access predefined variables of PHP i.e. values of $_server array in my webpage but i am not able to get them. Below is the code snippet for the same..

$script_directory = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'));
$included_directory = substr(__FILE__, 0, strrpos(__FILE__, '/'));

When i try to display these variable on my webpage i am not able to get anything i.e. getting blank value...
Has anyone encountered the same problem before? I read somewhere that values of predefined variables is dependent on type of webservers. Some servers supply the values to predefined variables and some not. Please let me know if my understanding is fine or not. TIA

Re: Values missing values in $_server array

Posted: Sun May 02, 2010 4:09 am
by ankgne
I figured it out myself :mrgreen: ....by default use of predefined variables is set to off in php.ini....i changed the 'register_globals' parameter to On in php.ini and it worked for me....

Re: Values missing values in $_server array

Posted: Sun May 02, 2010 6:38 am
by requinix
ankgne wrote:I figured it out myself :mrgreen: ....by default use of predefined variables is set to off in php.ini....i changed the 'register_globals' parameter to On in php.ini and it worked for me....
No. No no no. Do not use register_globals.

That setting has absolutely no effect on the code you posted. Something else is wrong.

Re: Values missing values in $_server array

Posted: Sun May 02, 2010 10:55 pm
by ankgne
tasairis wrote: No. No no no. Do not use register_globals.

That setting has absolutely no effect on the code you posted. Something else is wrong.
Oh but it worked for me...though setting of global_registers to "On" is not recommended as this can make one's code vulenrable to attacks....

Re: Values missing values in $_server array

Posted: Sun May 02, 2010 11:38 pm
by requinix
ankgne wrote:though setting of global_registers to "On" is not recommended as this can make one's code vulenrable to attacks....
Right. Which is why you should not use it.

I'm saying, register_globals has no effect upon the code you posted. Whether it's on or off doesn't matter.
If it does matter then it's influencing something else. Not that code.

Re: Values missing values in $_server array

Posted: Mon May 03, 2010 12:19 am
by ankgne
tasairis wrote:
I'm saying, register_globals has no effect upon the code you posted. Whether it's on or off doesn't matter.
If it does matter then it's influencing something else. Not that code.
Ok i'll check it once again thanks for the info...