Content
CODEExeccurlbrowsecommand line
Reference
CODE
<?php
var_dump(php_sapi_name());
//judge exec environment
if( substr(php_sapi_name(), 0, 3) === 'cli') {
echo 'yes!';
} else {
echo 'no!';
}
?>
Exec
curl
$ curl http://127.0.0.1/test.php
string(8) "fpm-fcgi"
no!
browse
http://127.0.0.1/test.php
string(8) "fpm-fcgi" no!
command line
$ php test.php
string(3) "cli"
yes!
Reference
https://www.php.net/manual/en/function.php-sapi-name.php