1. php
  2. /references
  3. /network-functions

PHP Network Functions

PHP Network functions can be used to open network connections, send and receive data over the network, and perform other tasks such as checking DNS records, resolving hostnames and IP addresses, and sending HTTP headers.

Common examples of PHP network functions include fsockopen() (which opens a network connection), dns_get_record() (which retrieves DNS resource records for a given domain), and gethostbyname() (which resolves a hostname to an IP address).

Here is a complete list and brief description on each:

FunctionDescriptionDeprecated
checkdnsrr()Check DNS records for a given domainNo
closelog()Close connection to system loggerNo
dns_check_record()Check DNS records for a given domainNo
dns_get_mx()Get MX records for a given domainNo
dns_get_record()Get DNS resource records for a domainNo
fsockopen()Open a network connectionNo
gethostbyaddr()Get the hostname for a given IP addressNo
gethostbyname()Get the IP address for a given hostnameNo
gethostbynamel()Get the IP addresses for a given hostnameNo
getmxrr()Get MX records for a given domainNo
getprotobyname()Get protocol number for a protocol nameNo
getprotobynumber()Get protocol name for a protocol numberNo
getservbyname()Get port number for a service nameNo
getservbyport()Get service name for a port numberNo
header()Send a raw HTTP headerNo
inet_ntop()Convert a packed IPv4/IPv6 address to a human-readable stringNo
inet_pton()Convert a human-readable IP address to a packed stringNo
long2ip()Convert an long integer to an IP addressNo
openlog()Open connection to system loggerNo
pfsockopen()Open a persistent network connectionNo
setcookie()Send a cookieNo
setrawcookie()Send a raw HTTP cookieNo
socket_get_status()Get the status of a socketNo
syslog()Send a message to the system loggerNo
define_syslog_variables()Initialize syslog variablesYes
dl()Load a PHP extension at runtimeYes
php_uname()Return information about the system PHP is running onYes
PHP_OSA predefined constant containing the operating system PHP is running onYes
PHP_OS_FAMILYA predefined constant containing the operating system family PHP is running onYes
PHP_SAPIA predefined constant containing the type of interface PHP is using to communicate with the web serverYes

It is worth noting that many PHP network functions are based on the underlying C library functions for network programming, such as socket(), connect(), and send(). As such, they may be more low-level and require a deeper understanding of network programming concepts to use effectively.