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
Values missing values in $_server array
Moderator: General Moderators
Re: Values missing values in $_server array
I figured it out myself
....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
No. No no no. Do not use register_globals.ankgne wrote:I figured it out myself....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....
That setting has absolutely no effect on the code you posted. Something else is wrong.
Re: Values missing values in $_server array
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....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.
Re: Values missing values in $_server array
Right. Which is why you should not use it.ankgne wrote:though setting of global_registers to "On" is not recommended as this can make one's code vulenrable to attacks....
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
Ok i'll check it once again thanks for the info...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.