is-cli.php

master
Anthony Axenov 2022-01-11 08:11:08 +08:00
parent 6133849718
commit ed3a5e044f
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC
3 changed files with 14 additions and 2 deletions

12
php/is-cli.php 100644
View File

@ -0,0 +1,12 @@
<?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']));
}