开发者

How to get response from web-site where is using console application?

开发者 https://www.devze.com 2023-02-13 15:09 出处:网络
It is for windows only. The main aim is to identify who does php-script run - browser or cron. Therefor开发者_StackOverflow社区e I would like to get print of $_SERVER in console application and under

It is for windows only.

The main aim is to identify who does php-script run - browser or cron. Therefor开发者_StackOverflow社区e I would like to get print of $_SERVER in console application and understand what is the difference.

May be someone knows how to identify request from cron.

Thanks to all in advance!


I believe you can test $_SERVER['HTTP_HOST']. If it is not set it's via the CLI, otherwise it's a browser. That is:

if(isset($_SERVER['HTTP_HOST'])) {
   echo "Browser!";
} else {
   echo "CLI!";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号