Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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