How to check with PHP if the script is being run from the console or browser request?

后端 未结 6 1523
孤街浪徒
孤街浪徒 2021-02-02 05:58

I tried things like $_ENV[\'CLIENTNAME\'] == \'Console\' but that seems to work on only certain OS\'s (worked in windows, not linux).

I tried !empty($_ENV[\'SHELL\']) b

6条回答
  •  -上瘾入骨i
    2021-02-02 06:38

    I know this is an old question, but for the record, I see HTTP requests coming in without a User-Agent header and PHP does not automatically define HTTP_USER_AGENT in this case.

提交回复
热议问题