Home > Backend Development > PHP Tutorial > php如何在代码中判断运行方式是fastCgi还是CLI?

php如何在代码中判断运行方式是fastCgi还是CLI?

WBOY
Release: 2016-06-06 20:14:18
Original
1869 people have browsed it

如题,例如在一个方法中,如何判断当前进程是由php-fpm启动的,还是直接在命令行启动的?

回复内容:

如题,例如在一个方法中,如何判断当前进程是由php-fpm启动的,还是直接在命令行启动的?

php_sapi_name http://php.net/manual/en/function.php-sapi-name.php

http://php.net/php_sapi_name
PHP的几种SAPI:
php(cli,cli-server)
php-fpm(fpm-fcgi)
php-cgi(cgi-fcgi)
libphp.so(apache2handler)

<code>PHP_SAPI || php_sapi_name</code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template