======ping======
WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0
Send an ICMP ping and place the result in an array
====Description====
array
ping (
string
$host
)
This function sends an ICMP ping request to a host by name or IP address and returns connection information as an array.
====Parameter====
$host: A URI web address name (such as example.com) or an IP address (such as 172.16.254.1). If a URI is provided the function will attempt to resolve it to an IP address by DNS.
====Return Values====
A key/value array of connection status information:
^Key^Type^Description^
|response|int|1 if connection was successful, -1 if failure|
|time|int|Response time in ms|
|host|string|Host name or IP address as passed to the function|
|ip|string|IP Address that DNS returned for the host|
|seq|int|Incremental sequence number for ping|
====Example====
$res=ping("example.com");
?>
Sample result if no connection is established:
[$res] = Array (
(int) [response] => -1
(string) [host] => example.com
(string) [ip] => 0.0.0.0
(int) [seq] => 0
)
Sample result if a connection is successful:
[$res] = Array (
(int) [response] => 1
(int) [time] => 25
(string) [host] => example.com
(string) [ip] => 93.184.216.34
(int) [seq] => 2
)
====See Also====
[[fsockopen()]] - Open an internet socket connection with optional timeout