function drupal_is_cli

Detects whether the current script is running in a command-line environment.

4 calls to drupal_is_cli()
drupal_page_is_cacheable in drupal/core/includes/bootstrap.inc
Determines the cacheability of the current page.
drupal_session_start in drupal/core/includes/session.inc
Forcefully starts a session, preserving already set session data.
_drupal_bootstrap_page_header in drupal/core/includes/bootstrap.inc
Invokes hook_boot(), initializes locking system, and sends HTTP headers.
_drupal_log_error in drupal/core/includes/errors.inc
Logs a PHP error or exception and displays an error page in fatal cases.

File

drupal/core/includes/bootstrap.inc, line 3298
Functions that need to be loaded on every Drupal request.

Code

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