功 能
php_sapi_name 是用來檢測PHP運行環境的函式。
語 法
voidphp_sapi_name( void)
返回值
該函式返回一個描述PHP與WEB伺服器接口的小寫字元串。
例如: aolserver, apache, apache2filter, apache2handler, caudium, cgi(until PHP 5.3), cgi-fcgi, cli, continuity, embed, isapi, litespeed, milter, nsapi, phttpd, pi3web, roxen, thttpd, tux, webjames.
實 例
<?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";
}
?>