« It's November, which means... | Main | Not the help you were looking for »

There must be a more elegant answer

Does anyone know an elegant way to test, within a PHP script, if PHP is running as a CGI or as an Apache module?

Now Playing: She Wants To Play Hearts from Demolition by Ryan Adams

Comments

From the manual phpsapiname()

phpsapiname() returns a lowercase string which describes the type of interface between web server and PHP (Server API, SAPI). In CGI PHP, this string is “cgi”, in mod_php for Apache, this string is “apache” and so on.

Sweet, that’s just what I need. I was looking in the constants and external variables sections.

Post a comment