PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a friend who asked this question below and I am unable to answer so I am searching for someone who can. Can anyone answer this question?
I am looking for the code that allows you to ping an ip and port and when the ip and port are active then it shows a graphic and when it is not it shows a different graphic. I have tried a few things and have managed to make a pinger but i dont know how to integrate the graphic stuff
here is the pinger i made
If you want to display a graphic only if a host is alive you will need to check the return code from the system command. Otherwise you will display the graphic whether the host is up or not.
<?php
// ping host and port, direct to null to hide all the system ping garbage
$ping = "ping -c 1 123.456.789:123456 >/dev/null";
system($ping,$ret);
// a return of 0 means the host was alive, anything else and the packet did not make it back
if ($ret == 0) {
echo ""<img src="Alive image">";
flush();
}
else {
echo ""<img src="Down image">";
flush();
}
?>