I'd like to create a small IF procedure that will check if Twitter is available (unlike now, for example), and will return true or false.
Help :)
I'd like to create a small IF procedure that will check if Twitter is available (unlike now, for example), and will return true or false.
Help :)
With the following function you are just sending the pure ICMP packets using socket_create. I got the following code from a user note there. N.B. You must run the following as root.
Although you can't put this in a standard web page you can run it as a cron job and populate a database with the results.
So it's best suited if you need to monitor a site.
Here's one:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=8&txtCodeId=1786
Another:
Using shell_exec:
Another option (if you need/want to ping instead of send an HTTP request) is the Ping class for PHP. I wrote it for just this purpose, and it lets you use one of three supported methods to ping a server (some servers/environments only support one of the three methods).
Example usage:
this is php code I used, reply is usually like this:
So I used code like this:
ping
is available on almost every OS. So you could make a system call and fetch the result.