Returns true if PHP was invoked from command-line interface (shell)
public static isPhpCliMode ( ) : boolean | ||
return | boolean | true if PHP invoked as a CGI or from CLI |
if (Common::isPhpCliMode()) { echo "PHP is currently running in CLI mode."; } else { echo "PHP is not running in CLI mode."; }
use Piwik\Common; if (Common::isPhpCliMode()) { // Run CLI specific code here } else { // Run Non-CLI specific code here }In this example, the Common class is imported using the `use` statement. The isPhpCliMode function is then called to determine which code block to execute. If PHP is running in CLI mode, the first block of code is executed, otherwise the second block of code is executed. Therefore, the package library being used in these examples is the Piwik Common package, which provides various useful functions and utilities for PHP developers working with the Piwik analytics platform.
public static isPhpCliMode ( ) : boolean | ||
return | boolean | true if PHP invoked as a CGI or from CLI |