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

View File

@ -11,4 +11,4 @@ cd build
cmake ..
make
make install
```
```

View File

@ -94,4 +94,4 @@ Array
[total] => 1.46 Тб
[total_bytes] => 1600874422272
)
*/
*/

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']));
}