Skip to main content
Detect CLI in PHP Script
February 3, 2019

To detect if your PHP script is being called via a web client or via CLI, you can use the php_sapi_name function. If you use this simple code:

echo php_sapi_name();

Then from a web browser you will see either fpm-fcgi or cgi-fcgi (depending on PHP handler your site uses) and from CLI you will see cli.

No Comments yet!

Warning: Undefined array key "comment_author_url_web" in /home/galleryr/www/www/wp-content/themes/civihosting/functions.php on line 555

Leave a Reply

Your email address will not be published. Required fields are marked *