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 includes/bootstrap.inc
Determines the cacheability of the current page.
drupal_session_start in includes/session.inc
Starts a session forcefully, preserving already set session data.
_drupal_bootstrap_page_header in includes/bootstrap.inc
Invokes hook_boot(), initializes locking system, and sends HTTP headers.
_drupal_log_error in includes/errors.inc
Logs a PHP error or exception and displays an error page in fatal cases.

File

includes/bootstrap.inc, line 3805

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.