This is an old revision of the document!
array ping(string $host)
Sends an ICMP ping request to a host name (resolved via DNS) or an IP address and returns status as an array
Sample result if no connection is established: [$res] = Array ( (int) [response] ⇒ -1 (string) [host] ⇒ google.com (string) [ip] ⇒ 0.0.0.0 (int) [seq] ⇒ 0 )
Result when successful:
[$res] = Array ( (int) [response] ⇒ 1 (int) [time] ⇒ 25 (string) [host] ⇒ google.com (string) [ip] ⇒ 216.58.196.110 (int) [seq] ⇒ 2 )
Result array fields:
field | type | description |
response | int | -1 if failed, or else 1 |
time | int | response time in ms |
host | string | host name (passed to the call) |
ip | string | IP Address that DNS returned for the host |
seq | int | incremental sequence number for ping |