PHP constant PHP_SAPI and function php_sapi_name () Introduction. PHP runtime environment detection php_sapi_name () is a function used to detect the PHP runtime environment. This function returns a lowercase string describing the PHP and WEB server interfaces. For example, aolserver ,? Apache, apache2filter ,? Apache2handler ,? Caudium ,? Cgi (u PHP constant PHP_SAPI and function php_sapi_name () introduction, PHP runtime environment detection
Php_sapi_name () is a function used to detect the PHP runtime environment.
This function returns a lowercase string describing the PHP and WEB server interfaces.
For example: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.
++ ++
How to determine the PHP runtime environment?
When I read the ci code, I found that processing the URI is not needed according to the php runtime environment.
How can we determine the php runtime environment?
We generally run our php program under apache, and some of them use the IIS environment.
If we want to know what the current running environment is, we can use the php_sapi_name () function for testing,
Code:
? The output result in the apache environment is "apache2handler ";
In cgi mode, the output result is "cgi-fcgi"
If it is run in command line mode, the output result is: "cli"
Based on this content, we can determine what the current running environment is!
How can I run it in the command line?
As follows:
Enter the address where DOS enters the php.exe file. for example, my address is: d:/wamp/bin/php/php5.3.3/
Input php.exe "absolute file path", for example, php.exe d:/wamp/www/info. php.
You can.