function drush_verify_cli

8.0.x environment.inc drush_verify_cli()
6.x environment.inc drush_verify_cli()
7.x environment.inc drush_verify_cli()
3.x drush.php drush_verify_cli()
4.x drush.php drush_verify_cli()
5.x environment.inc drush_verify_cli()
master environment.inc 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.

File

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

Code

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