Reputation: 29
I am having issues getting my PHP script to display the response time to the IP of the visitor displaying in ms. I have already seen this: PHP - get server to ping a visitors IP and return the ping in ms
When I try to do some of the same code all mine outputs is
"8.8.8.8 is alive"
I'd actually like it to return the average round trip time or just the response time in milliseconds.
Here is my code that just outputs the above:
$pinginfo = array();
exec("/usr/sbin/ping -v -c 1 8.8.8.8", $pinginfo);
var_dump($pinginfo);
Upvotes: 0
Views: 2704
Reputation: 2006
try saving your exec result to the $pinginfo
$pinginfo = exec("/bin/ping -v -c 1 8.8.8.8");
echo $pinginfo;
the way you are doing it now, you're only saving the integer return value. The exec function returns the last string from the executed stdout.
Upvotes: 1