ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
提供一系列联网函数 * [预定义常量](https://www.php.net/manual/zh/network.constants.php) * [网络 函数](https://www.php.net/manual/zh/ref.network.php) * [checkdnsrr](https://www.php.net/manual/zh/function.checkdnsrr.php)— 给指定的主机(域名)或者IP地址做DNS通信检查 * [closelog](https://www.php.net/manual/zh/function.closelog.php)— 关闭系统日志链接 * [define\_syslog\_variables](https://www.php.net/manual/zh/function.define-syslog-variables.php)— 初始化所有与syslog相关的变量 * [dns\_check\_record](https://www.php.net/manual/zh/function.dns-check-record.php)— 别名 checkdnsrr * [dns\_get\_mx](https://www.php.net/manual/zh/function.dns-get-mx.php)— 别名 getmxrr * [dns\_get\_record](https://www.php.net/manual/zh/function.dns-get-record.php)— 获取指定主机的DNS记录 * [fsockopen](https://www.php.net/manual/zh/function.fsockopen.php)— 打开一个网络连接或者一个Unix套接字连接 * [gethostbyaddr](https://www.php.net/manual/zh/function.gethostbyaddr.php)— 获取指定的IP地址对应的主机名 * [gethostbyname](https://www.php.net/manual/zh/function.gethostbyname.php)— 返回主机名对应的 IPv4地址。 * [gethostbynamel](https://www.php.net/manual/zh/function.gethostbynamel.php)— 获取互联网主机名对应的 IPv4 地址列表 * [gethostname](https://www.php.net/manual/zh/function.gethostname.php)— 获取主机名 * [getmxrr](https://www.php.net/manual/zh/function.getmxrr.php)— 获取互联网主机名对应的 MX 记录 * [getprotobyname](https://www.php.net/manual/zh/function.getprotobyname.php)— 获取与协议名称关联的协议编号 * [getprotobynumber](https://www.php.net/manual/zh/function.getprotobynumber.php)— 获取与协议号关联的协议名 * [getservbyname](https://www.php.net/manual/zh/function.getservbyname.php)— 获取互联网服务协议对应的端口 * [getservbyport](https://www.php.net/manual/zh/function.getservbyport.php)— 获取与端口和协议相对应的Internet服务 * [header\_register\_callback](https://www.php.net/manual/zh/function.header-register-callback.php)— 调用一个 header 函数 * [header\_remove](https://www.php.net/manual/zh/function.header-remove.php)— 删除之前设置的 HTTP 头 * [header](https://www.php.net/manual/zh/function.header.php)— 发送原生 HTTP 头 * [headers\_list](https://www.php.net/manual/zh/function.headers-list.php)— 返回已发送的 HTTP 响应头(或准备发送的) * [headers\_sent](https://www.php.net/manual/zh/function.headers-sent.php)— 检测 HTTP 头是否已经发送 * [http\_response\_code](https://www.php.net/manual/zh/function.http-response-code.php)— 获取/设置响应的 HTTP 状态码 * [inet\_ntop](https://www.php.net/manual/zh/function.inet-ntop.php)— 将压缩的internet地址转换为人类可读的表示形式 * [inet\_pton](https://www.php.net/manual/zh/function.inet-pton.php)— 将人类可读的IP地址转换为其压缩在/\_addr中的表示形式 * [ip2long](https://www.php.net/manual/zh/function.ip2long.php)— 将 IPV4 的字符串互联网协议转换成长整型数字 * [long2ip](https://www.php.net/manual/zh/function.long2ip.php)— 将长整型转化为字符串形式带点的互联网标准格式地址(IPV4) * [openlog](https://www.php.net/manual/zh/function.openlog.php)— 打开到系统记录器的连接 * [pfsockopen](https://www.php.net/manual/zh/function.pfsockopen.php)— 打开一个持久的网络连接或者Unix套接字连接。 * [setcookie](https://www.php.net/manual/zh/function.setcookie.php)— 发送 Cookie * [setrawcookie](https://www.php.net/manual/zh/function.setrawcookie.php)— 发送未经 URL 编码的 cookie * [socket\_get\_status](https://www.php.net/manual/zh/function.socket-get-status.php)— 别名 stream\_get\_meta\_data * [socket\_set\_blocking](https://www.php.net/manual/zh/function.socket-set-blocking.php)— 别名 stream\_set\_blocking * [socket\_set\_timeout](https://www.php.net/manual/zh/function.socket-set-timeout.php)— 别名 stream\_set\_timeout * [syslog](https://www.php.net/manual/zh/function.syslog.php)— 生成系统日志消息 [getprotobyname](https://www.php.net/manual/zh/function.getprotobyname.php)— 获取与协议名称关联的协议编号 ``` //getprotobyname()给出本地系统上给定协议名称的协议号 $arr=array("ip","icmp","ggp","tcp", "egp","pup","udp","hmp","xns-idp", "rdp","rvd" ); //Reads the names of protocols into an array.. for($i=0;$i<11;$i++) { $proname=$arr[$i]; echo $proname .":", getprotobyname ($proname)."<br />"; } 结果: ip:0 icmp:1 ggp:3 tcp:6 egp:8 pup:12 udp:17 hmp:20 xns-idp:22 rdp:27 rvd:66 ``` [getservbyname](https://www.php.net/manual/zh/function.getservbyname.php)— 获取互联网服务协议对应的端口 ``` $services = array('http', 'ftp', 'ssh', 'telnet', 'imap', 'smtp', 'nicname', 'gopher', 'finger', 'pop3', 'www'); foreach ($services as $service) { $port = getservbyname($service, 'tcp'); echo $service . ": " . $port . "<br />\n"; } ``` [gethostbyname](https://www.php.net/manual/zh/function.gethostbyname.php)— 返回主机名对应的 IPv4地址。 [gethostbynamel](https://www.php.net/manual/zh/function.gethostbynamel.php)— 获取互联网主机名对应的 IPv4 地址列表 ``` $address = gethostbyname('www.example.com'); ```