Values missing values in $_server array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ankgne
Forum Newbie
Posts: 6
Joined: Tue Apr 27, 2010 1:44 am

Values missing values in $_server array

Post 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
ankgne
Forum Newbie
Posts: 6
Joined: Tue Apr 27, 2010 1:44 am

Re: Values missing values in $_server array

Post 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....
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Values missing values in $_server array

Post 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.
ankgne
Forum Newbie
Posts: 6
Joined: Tue Apr 27, 2010 1:44 am

Re: Values missing values in $_server array

Post 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....
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Values missing values in $_server array

Post 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.
ankgne
Forum Newbie
Posts: 6
Joined: Tue Apr 27, 2010 1:44 am

Re: Values missing values in $_server array

Post 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...
Post Reply