Piwik\Common::isPhpCliMode PHP Méthode

isPhpCliMode() public static méthode

Returns true if PHP was invoked from command-line interface (shell)
public static isPhpCliMode ( ) : boolean
Résultat boolean true if PHP invoked as a CGI or from CLI
    public static function isPhpCliMode()
    {
        if (is_bool(self::$isCliMode)) {
            return self::$isCliMode;
        }
        if (PHP_SAPI == 'cli') {
            return true;
        }
        if (self::isPhpCgiType() && (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR']))) {
            return true;
        }
        return false;
    }

Usage Example

 public static function handleException(Exception $exception)
 {
     if (Common::isPhpCliMode()) {
         self::dieWithCliError($exception);
     }
     self::dieWithHtmlErrorPage($exception);
 }
All Usage Examples Of Piwik\Common::isPhpCliMode