php_sapi_name

(PHP 4 >= 4.0.1, PHP 5)

php_sapi_name --  Returns the type of interface between web server and PHP

Description

string php_sapi_name ( void )

php_sapi_name() 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.

例子 1. php_sapi_name() example

<?php
$sapi_type
= php_sapi_name();
if (
substr($sapi_type, 0, 3) == 'cgi') {
    echo
"You are using CGI PHP\n";
} else {
    echo
"You are not using CGI PHP\n";
}
?>


add a note add a note User Contributed Notes
cheezy at lumumba dot luc dot ac dot be
14-Jul-2003 12:11
The returned strings can be found in the source code (of course!), this is the list I found (using [ http://lxr.php.net/ident?i=sapi_module_struct ]):

- aolserver
- activescript
- apache
- cgi-fcgi
- cgi
- isapi
- nsapi
- phttpd
- roxen
- java_servlet
- thttpd
- pi3web
- apache2filter
- caudium
- apache2handler
- tux
- webjames
- cli
- embed
- milter