Example using fping
(You could use piong instead, but if you install fping you can limit the time)
<?php
$cfg_endpoint = "www.google.com";
echo ("<p>Pinging $cfg_endpoint:</p>");
echo ("<p>Result:</p>");
//----- DO THE PING -----
$output = shell_exec("fping -c1 -t750 $cfg_endpoint 2>&1");
echo "<pre>$output</pre>";
?>
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.