NYCPHP Meetup

NYPHP.org

[nycphp-talk] $_SERVER

Nate Abele nate at cakephp.org
Sun May 27 12:15:15 EDT 2007


> Date: Sat, 26 May 2007 20:23:27 -0400
> From: David Krings <ramons at gmx.net>
> Subject: [nycphp-talk] $_SERVER
> To: NYPHP Talk <talk at lists.nyphp.org>
>
> Hi!
>
> Every web server generates a different $_SERVER array in PHP. I got
> burnt by it once. I used several keys/values that are present in the
> Luckasoft EnginServer, but not in Apache. I am sure that IIS again  
> has a
> different $_SERVER and the whole picture may look different on  
> Linux or
> Mac OS.
>
> The question of the day is: Which keys/values are guaranteed to be
> present in $_SERVER on all/most of the modern servers?
>
> David

Hi David,

This may or may not be helpful for your specific situation, but I  
wrote a $_SERVER compatibility layer into Cake in the form of an env 
() function, which you can check out here:

https://trac.cakephp.org/browser/branches/1.2.x.x/cake/basics.php#L978

It's not super-comprehensive, but it covers the basics, and uses  
fallback accessors if the $_SERVER variable is disabled entirely (I  
know Yahoo! does this, as there are some advantages in reduced  
overhead).

- Nate




More information about the talk mailing list