Created
August 7, 2020 14:07
-
-
Save anthonyaxenov/c1b237af14ec91aead19be66cdfc29e3 to your computer and use it in GitHub Desktop.
[PHP] Проверить запущен ли скрипт из терминала
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Определяет запущен ли скрипт через php-cli | |
* Checks if script running under php-cli | |
* | |
* @return bool | |
*/ | |
function is_cli(): bool | |
{ | |
return PHP_SAPI === 'cli' | |
|| (!isset($_SERVER['DOCUMENT_ROOT']) && !isset($_SERVER['REQUEST_URI'])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment