Home » Networking » Net_Ping » Manual
API for the Ping command
Net_Ping::Net_Ping()
Net_Ping::Net_Ping() – constructor
Synopsis
require_once 'Net/Ping.php';
void
Net_Ping::Net_Ping
(
)
Description
Please use Net_Ping::factory() instead of using this constructor directly.
Net_Ping::ping()
Net_Ping::ping() – executes a ping command
Synopsis
require_once 'Net/Ping.php';
string
Net_Ping::ping (
string
host
)
Description
Executes a ping command
Parameter
-
string $host- the name of the server or the IP-adress
Return value
string -
the return message of the ping command
Note
This function can not be called statically.
Example
Sending a ping request
<?php
require_once "Net/Ping.php";
$ping = Net_Ping::factory();
if (PEAR::isError($ping)) {
echo $ping->getMessage();
} else {
$ping->setArgs(array('count' => 2));
var_dump($ping->ping('example.com'));
}
?>
Net_Ping::setArgs()
Net_Ping::setArgs() – set arguments for a ping command
Synopsis
require_once 'Net/Ping.php';
boolean
Net_Ping::setArgs (
array
$args
)
Description
Set the arguments for a ping command
Parameter
-
array $args- an array of the arguments to setpossible array keys Key name Description NOT supported on "count" Number of ping packages to send "quiet" Level of output verbosity Windows "iface" FreeBSD, Linux, Windows "ttl" "timeout" Time to wait for a ACK of a ping package "size" Size of a ping package FreeBSD, Darwin, Linux, Windows
Return value
boolean -
Returns TRUE on success,
PEAR_Error on failure.
Throws
| Error code | Error message | Reason | Solution |
|---|---|---|---|
| NULL | PING_INVALID_ARGUMENTS | A not supported argument was given | Check typing of argument (key name) and OS-support of the argument. |
Note
This function can not be called statically.