vk | autocomplete jquery ajax | How to post automatic comment in group post | jquery autocomplete database


Determine PHP script Invocation: CLI or by the Web Server

In most cases you can distinguish if a PHP script was invoked from the command line (or Cron) or by the web server, using php_sapi_name().

php_sapi_name() will return cli on CLI (or Cron) invocation and some other values on invocation by Web Server (e.g. apache2handler for Apache).


A simple example:

if(php_sapi_name() == 'cli') {
	// your code here
} else {
	// your code here

Your comments are welcomed!


From PHP manual

Sign-up for our free email newsletter. Get updates when new tutorials and tips are published. You can unsubscribe anytime with a click.

Your comments are welcomed!

This site actively encourages commenting on any post. Comments are not pre-moderated, but this community does not tolerate direct or indirect attacks, name-calling or insults. Please, read terms of use and Comment Policy at privacy policy.

More tips