How to ping from php

< ?php
  function ping($host) {
    exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
    return $rval === 0;
  }

  $hosts_to_ping = array('127.0.0.1');
?>
< ?php foreach ($hosts_to_ping as $host): ?>
    < ?php echo $host; ?>
    < ?php $up = ping($host); ?>
    < ?php echo $up ? 'on' : 'off'; ?>
< ?php endforeach; ?>

FacebookTechnotiziePlaxo PulseLinkedInTwitterWordPressGoogle BookmarksGoogle ReaderStumbleUponTechnorati FavoritesShare

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

If you found this page useful, consider linking to it.
Simply copy and paste the code below into your web site (Ctrl+C to copy)
It will look like this: How to ping from php

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera