Ping ip in php
Posted: Fri Jul 21, 2006 12:08 pm
What is the best way to ping anIP in php and determine if it is live or not?
Thanks!
Thanks!
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
PHP doesn't have even the slightest ability to send icmp packets (ping).GeXus wrote:What is the best way to ping anIP in php and determine if it is live or not?
Thanks!
wtf wrote:PEAR Net_Ping will do the job
Code: Select all
if(!fopen("http://www.your-url_or_your-ip-here","r")){
Take some action! (IE -- Page yourself)
}It exec's shell commands.d11wtq wrote:Does that use shell commands or native PHP code? Sorry, I havent looked at it but figured you might already know.
That would, at best, tell you if the URL or IP responds to HTTP requests. Failing does not mean that it does not exist or isn't live unfortunately.siefkencp wrote:You can always use this (if its what your trying to accomplish...
Hope that helps!Code: Select all
if(!fopen("http://www.your-url_or_your-ip-here","r")){ Take some action! (IE -- Page yourself) }