Posted By

KrisBaur on 07/12/11


Tagged

php ping icmp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


PHP PING


 / Published in: PHP
 

Found on php.net

  1. <?php
  2. function GetPing($ip=NULL) {
  3. if(empty($ip)) {$ip = $_SERVER['REMOTE_ADDR'];}
  4. if(getenv("OS")=="Windows_NT") {
  5. $exec = exec("ping -n 3 -l 64 ".$ip);
  6. return end(explode(" ", $exec ));
  7. }
  8. else {
  9. $exec = exec("ping -c 3 -s 64 -t 64 ".$ip);
  10. $array = explode("/", end(explode("=", $exec )) );
  11. return ceil($array[1]) . 'ms';
  12. }
  13. }
  14.  
  15. echo GetPing();
  16. ?>

Report this snippet  

You need to login to post a comment.