How to Make a Ping tool in PHP

How to Make a Ping tool in PHP

Ping toll in PHP doesn't have to be hard. We have made a simple easy to follow guide on how to make a ping tool in PHP

Here a small piece of code for Ping tool in PHP that pings to hosts via o.s . Only trick abot this script is that it calls the system routines for perfom function,nice feature of server side scripting.The script can be run on Linux as well as Windows by detect the server o.s itself.

The Power of PHP could be integrated with with os to perform basic operations, like this.

ping

Enjoy the Ping tool in PHP:

Ping tool


enter host name or ip address:


//ping tool in php
$host = “”;
if(isset($_POST[‘t1’]) && $_POST[‘t1’]!= “”)
{
$host = $_POST[‘t1’];
}
else
{
die(“please select a host to ping”);
}
echo “ping results for $host

”;
$p1 = “ping -l 2 $host”;
$p2 = “ping -n 2 $host”;
if(exec(“uname”))
{
echo “
”;
system($p1);
}
if(exec(“ver”))
{
echo “
”;
system($p2);
}
?>