PHP constant Php_sapi and function php_sapi_name () Introduction, PHP Run environment detection
Php_sapi_name () is a function used to detect the PHP runtime environment.
This function returns a lowercase string that describes the interface between PHP and the Web server.
For example:aolserver,? Apache,apache2filter,? Apache2handler, huh? caudium, huh? CGI (until PHP 5.3),cgi-fcgi,? CLI,? continuity, huh? embed, huh? ISAPI,? Litespeed, huh? milter, huh? Nsapi, huh? phttpd, huh? pi3web, huh? Roxen,thttpd,? Tux, huh? webjames.
++++++++++++++++++++++++++++++++++++++++++++++++++++++
How can I tell the environment of PHP operation?
During the reading of the CI code, the processing URI is not processed according to the operating environment of PHP.
So how do you judge PHP's operating environment?
In general, we run our PHP programs under Apache, and of course some people are using the IIS environment.
If we want to know what our current environment is, we can use the function php_sapi_name () to test it,
Code:
? The result of output under Apache environment is "Apache2handler";
The result of the output in CGI mode is "cgi-fcgi"
If you run under command-line mode, the result of the output is: "CLI"
Based on this content, we can determine what the current operating environment is!
So how do you run it under the command line?
As follows:
Enter DOS to enter the address of the Php.exe file as mine is: d:/wamp/bin/php/php5.3.3/
Then enter Php.exe "absolute path to file" such as: >php.exe d:/wamp/www/info.php
You can do it.