shell - How to check with PHP if the script is being run from the console or browser request? -
I tried things like $ _ENV ['CLIENTNAME'] == 'console' but it only works on some OS It seems (worked in windows, not Linux)
I tried! Empty ($ _ ENV ['SHELL']), but it does not always work either ...
Is there any way to check that OS / environment will work in all?
Thank you!
Usage
Returns a lowercase string, which is the type of interface ( Server API, SAPI), which is using PHP. For example, this string in CLI PHP will be "cli", whereas with Apache it can have many different values depending on the exact SAPI. For example:
$ isCLI = (php_sapi_name () == 'cli');
You can also continuously use
PHP_SAPI
Comments
Post a Comment