This new post from the SitePoint PHP blog today looks at some of the differences in the APIs that PHP offers.
Some work has been done to provide SAPI-specific functionality to help "understand" parts of the environment but, IMO, the bottom line is there's a minefield if you're writing code that should run under more than one SAPI.
If you've written code that's had to run under more than one web server environment (even PHP as CGI vs. PHP as module under Apache), you've probably run into headaches like $_SERVER['SCRIPT_FILENAME'] being unavailable—Server APIs (SAPIs) vary.
There are a lot of places where this kind of thing pops up, not just in the $_SERVER variables. Of course, it would be nice to have a "magic API" like Harry mentions that would handle it all for you...




