What are the potential factors that can affect the response time when pinging a host?
Potential factors that can affect the response time when pinging a host include network congestion, the distance between the host and the sender, the quality of the network connection, and the load on the host's server. To improve response time, you can try optimizing the network connection, choosing a closer host, or reducing the load on the server.
<?php
$host = 'example.com';
exec("ping -c 4 $host", $output, $result);
echo "Response time: " . $output[1];
?>