gists/php/is-cli.php

14 lines
371 B
PHP
Raw Normal View History

2022-01-11 00:11:08 +00:00
<?php
/**
* Определяет запущен ли скрипт через php-cli
* Checks if script running under php-cli
*
* @return bool
2022-01-11 00:13:24 +00:00
* @see https://gist.github.com/anthonyaxenov/c1b237af14ec91aead19be66cdfc29e3
2022-01-11 00:11:08 +00:00
*/
function is_cli(): bool
{
return PHP_SAPI === 'cli'
|| (!isset($_SERVER['DOCUMENT_ROOT']) && !isset($_SERVER['REQUEST_URI']));
}