2017 © Pedro Peláez
 

library ping

A PHP class to ping hosts.

image

ne0bot/ping

A PHP class to ping hosts.

  • Tuesday, January 30, 2018
  • by ne0bot
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 105 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Ping for PHP Logo, (*1)

Ping

Total Downloads Build Status, (*2)

A PHP class to ping hosts., (*3)

There are a ton of different methods of pinging a server using PHP, and I've found most to be poorly documented or downright dangerous in their implementation., (*4)

Therefore, I've created this simple class, which incorporates the three most popular ping methods (exec() with the system's ping utility, fsockopen(), and socket_create()). Each method has it's benefits and drawbacks, and may work better or worse on a particular system., (*5)

Ping was created by Jeff Geerling of Midwestern Mac, LLC in 2012., (*6)

Usage

This is a very simple class. Just create an instance, and run ping()., (*7)

$host = 'www.example.com';
$ping = new Ping($host);
$latency = $ping->ping();
if ($latency !== -1) {
  print 'Latency is ' . $latency . ' ms';
}
else {
  print 'Host could not be reached.';
}

You can also specify the ttl (maximum hops) and timeout when creating the instance:, (*8)

$ttl = 128;
$timeout = 5;
$ping = new Ping($host, $ttl, $timeout);

...or using the setTtl() or setTimeout() methods:, (*9)

$ping = new Ping($host);
$ping->setTtl(128);
$ping->setTimeout(5);

You can change the host using the setHost() method:, (*10)

$ping = new Ping($host);
...
$ping->setHost('www.anotherexample.com');

License

Ping is licensed under the MIT (Expat) license. See included LICENSE.md., (*11)

The Versions

30/01 2018

1.x-dev

1.9999999.9999999.9999999-dev

A PHP class to ping hosts.

  Sources   Download

MIT

02/02 2017

1.1.2

1.1.2.0

A PHP class to ping hosts.

  Sources   Download

MIT

04/06 2016

1.1.1

1.1.1.0

A PHP class to ping hosts.

  Sources   Download

MIT

04/06 2016

1.1.0

1.1.0.0

A PHP class to ping hosts.

  Sources   Download

MIT

05/06 2015

1.0.3

1.0.3.0

A PHP class to ping hosts.

  Sources   Download

MIT

26/01 2015

1.0.2

1.0.2.0

A PHP class to ping hosts.

  Sources   Download

MIT

27/06 2014

1.0.1

1.0.1.0

A PHP class to ping hosts.

  Sources   Download

MIT

31/01 2014

1.0.0

1.0.0.0

A PHP class to ping hosts.

  Sources   Download

MIT