PHP constant Php_sapi and function php_sapi_name () Introduction, PHP Run environment detection

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

  • 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.