PHP constant PHP_SAPI and function php_sapi_name () introduction, PHP runtime environment detection

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.