curl and ping - how to check whether a website is either up or down?

后端 未结 7 2161
再見小時候
再見小時候 2020-11-28 12:51

I want to check whether a website is up or down at a particular instance using PHP. I came to know that curl will fetch the contents of the file but I don\'t want to read th

7条回答
  •  孤独总比滥情好
    2020-11-28 13:06

    ping won't do what you're looking for - it will only tell you if the machine is up (and responding to ping). That doesn't necessarily mean that the webserver is up, though.

    You might want to try using the http_head method - it'll retrieve the headers that the webserver sends back to you. If the server is sending back headers, then you know it's up and running.

提交回复
热议问题