function drush_verify_cli

8.0.x drush_verify_cli()
6.x drush_verify_cli()
7.x drush_verify_cli()
3.x drush.php drush_verify_cli()
4.x drush.php drush_verify_cli()
5.x drush_verify_cli()
master drush_verify_cli()

Verify that we are running PHP through the command line interface.

This function is useful for making sure that code cannot be run via the web server, such as a function that needs to write files to which the web server should not have access to.

Return value

A boolean value that is true when PHP is being run through the command line, and false if being run through cgi or mod_php.


./drush.php, line 54
drush is a PHP script implementing a command line shell for Drupal.


function drush_verify_cli() {
  return (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0));