Ahmed-Anas
Ahmed-Anas

Reputation: 5639

check if site available through ip via php

was hoping you could help me out.

I am trying to check if a site(actually multiple sites, put I can do that part my self :p ) is online or offline via their IP address. Ive searched a bit and found out two methods to do this

wanted to know which was the better, and more reliable method. or is there another method that I am missing?

I read that using the curl library was the best method, but I couldnt figure out how to make that work with an IP address (and not a link). also, i'd rather not use a library that isnt pre-installed unless it makes a big difference.

Upvotes: 0

Views: 395

Answers (1)

Rob Agar
Rob Agar

Reputation: 12469

It really depends on what you mean by "online". Ping will tell you if there is a host with the given IP address which responds to ping requests (most do, but some are configured not to. Or there might be an unhelpful router somewhere in between you and the host which doesn't pass on the packets)

Something like curl will be more useful if you actually want to know whether the host is a functioning HTTP server. You could check the returned status is 200 for example.

Upvotes: 1

Related Questions