User Tools

Site Tools


uphp:functions:ping

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:

fieldtypedescription
responseint-1 if failed, or else 1
timeintresponse time in ms
hoststringhost name (passed to the call)
ipstringIP Address that DNS returned for the host
seqintincremental sequence number for ping
uphp/functions/ping.1494675945.txt.gz · Last modified: 2021/09/13 05:56 (external edit)