Skip to content

Instantly share code, notes, and snippets.

@anthonyaxenov
Created August 7, 2020 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyaxenov/c1b237af14ec91aead19be66cdfc29e3 to your computer and use it in GitHub Desktop.
Save anthonyaxenov/c1b237af14ec91aead19be66cdfc29e3 to your computer and use it in GitHub Desktop.
[PHP] Проверить запущен ли скрипт из терминала
/**
* Определяет запущен ли скрипт через 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