网络 函数 业 ,精于勤 荒于嬉.

网络 函数 checkdnsrr 给指定的主机(域名)或者IP地址做DNS通信检查

发表日期:2021-07-01 08:56:40 | 来源: | 分类:网络 函数

checkdnsrr

(PHP 4, PHP 5, PHP 7, PHP 8)

checkdnsrr给指定的主机(域名)或者IP地址做DNS通信检查

说明

checkdnsrr(string $host, string $type = "MX"): bool

根据不同记录(type)类型查询主机(host)相应的DNS记录。

参数

host

主机(host)可以是一个IP地址也可以是域名。

type

解析记录类型(type)可能是下面这些类型中的任何一个:A,MX,NS,SOA,PTR,CNAME,AAAA,A6, SRV,NAPTR,TXT 或者 ANY。

返回值

如果记录能找到,就返回true;如果查找不到该DNS记录或者发生了错误,就返回false

更新日志

版本 说明
5.3.0 这个函数在Windows平台上也可以使用了。
5.2.4 增加了TXT的记录类型
5.0.0 增加了AAAA的记录类型

注释

注意:

出于对低版本在windows平台上的兼容性,可以试试» PEAR扩展包里面提供的 » Net_DNS类。

参见

阅读全文 »

网络 函数 closelog 关闭系统日志链接

发表日期:2021-07-01 08:56:40 | 来源: | 分类:网络 函数

closelog

(PHP 4, PHP 5, PHP 7, PHP 8)

closelog关闭系统日志链接

说明

closelog(): bool

closelog() 关闭用于通信的描述符并写入系统日志。closelog()是可选的。

返回值

成功时返回 true, 或者在失败时返回 false

参见

  • syslog() - Generate a system log message
  • openlog() - Open connection to system logger

阅读全文 »

网络 函数 dns_check_record 别名 checkdnsrr()

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

dns_check_record

(PHP 5, PHP 7, PHP 8)

dns_check_record别名 checkdnsrr()

说明

此函数是该函数的别名: checkdnsrr()

阅读全文 »

网络 函数 dns_get_mx 别名 getmxrr()

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

dns_get_mx

(PHP 5, PHP 7, PHP 8)

dns_get_mx别名 getmxrr()

说明

此函数是该函数的别名: getmxrr()

阅读全文 »

网络 函数 dns_get_record 获取指定主机的DNS记录

发表日期:2021-07-01 08:56:40 | 来源: | 分类:网络 函数

      示例1
<?php 
$result = dns_get_record("php.net");
print_r($result);
?>

      示例2
<?php 
/* Request "ANY" record for php.net,   and create $authns and $addtl arrays   containing list of name servers and   any additional records which go with   them */
$result = dns_get_record("php.net", DNS_ANY, $authns, $addtl);
echo "Result = ";
print_r($result);
echo "Auth NS = ";
print_r($authns);
echo "Additional = ";
print_r($addtl);
?>

阅读全文 »

网络 函数 fsockopen 打开一个网络连接或者一个Unix套接字连接

发表日期:2021-07-01 08:56:40 | 来源: | 分类:网络 函数

      示例1
<?php 
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
}
 else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}
?>

      示例2
<?php 
$fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
}
 else {
    fwrite($fp, "\n");
    echo fread($fp, 26);
    fclose($fp);
}
?>

阅读全文 »

网络 函数 gethostbyaddr 获取指定的IP地址对应的主机名

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo $hostname;
?>

阅读全文 »

网络 函数 gethostbyname 返回主机名对应的 IPv4地址。

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
$ip = gethostbyname('www.example.com');
echo $ip;
?>

阅读全文 »

网络 函数 gethostbynamel 获取互联网主机名对应的 IPv4 地址列表

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
$hosts = gethostbynamel('www.example.com');
print_r($hosts);
?>

阅读全文 »

网络 函数 gethostname 获取主机名

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
echo gethostname();
 // may output e.g,: sandie// Or, an option that also works before PHP 5.3echo php_uname('n');
 // may output e.g,: sandie?>

阅读全文 »

网络 函数 getmxrr 获取互联网主机名对应的 MX 记录

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

getmxrr

(PHP 4, PHP 5, PHP 7, PHP 8)

getmxrr获取互联网主机名对应的 MX 记录

说明

getmxrr(string $hostname, array &$mxhosts, array &$weight = ?): bool

搜索 hostname对应的 MX DNS 记录。

参数

hostname

互联网主机名。

mxhosts

找到的 MX 记录列表存放于 mxhosts 数组。

weight

提供了 weight 数组后,它会用找到的权重信息填充数组。

返回值

找到记录返回 true,没找到或者出错时返回 false

更新日志

版本 说明
5.3.0 Windows 平台上也能用这个函数了。

注释

注意:

本函数不应使用于地址验证。 仅在 MX 记录在 DNS 中找到时才会返回,然而根据 » RFC 2821, 没有 MX 记录时, hostname 本身就是 MX 主机,优先级为 0

注意:

在兼容 Windows 实现之前的版本, 可以使用 » PEAR class 的 » Net_DNS

参见

阅读全文 »

网络 函数 getprotobyname Get protocol number associated with protocol name

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
$protocol = 'tcp';
$get_prot = getprotobyname($protocol);
if ($get_prot === FALSE) {
    echo 'Invalid Protocol';
}
 else {
    echo 'Protocol #' . $get_prot;
}
?>

阅读全文 »

网络 函数 getprotobynumber Get protocol name associated with protocol number

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

getprotobynumber

(PHP 4, PHP 5, PHP 7, PHP 8)

getprotobynumberGet protocol name associated with protocol number

说明

getprotobynumber(int $protocol): string|false

getprotobynumber() returns the protocol name associated with protocol protocol as per /etc/protocols.

参数

protocol

The protocol number.

返回值

Returns the protocol name as a string, 或者在失败时返回 false.

参见

阅读全文 »

网络 函数 getservbyname 获取互联网服务协议对应的端口

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?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";
}
?>

阅读全文 »

网络 函数 getservbyport Get Internet service which corresponds to port and protocol

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

getservbyport

(PHP 4, PHP 5, PHP 7, PHP 8)

getservbyportGet Internet service which corresponds to port and protocol

说明

getservbyport(int $port, string $protocol): string|false

getservbyport() returns the Internet service associated with port for the specified protocol as per /etc/services.

参数

port

The port number.

protocol

protocol is either "tcp" or "udp" (in lowercase).

返回值

Returns the Internet service name as a string, 或者在失败时返回 false.

参见

阅读全文 »

网络 函数 header_register_callback 调用一个 header 函数

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
header('Content-Type: text/plain');
header('X-Test: foo');
function foo() {
 foreach (headers_list() as $header) {
   if (strpos($header, 'X-Powered-By:') !== false) {
     header_remove('X-Powered-By');
   }
   header_remove('X-Test');
 }
}
$result = header_register_callback('foo');
echo "a";
?>

阅读全文 »

网络 函数 header_remove 删除之前设置的 HTTP 头

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
header("X-Foo: Bar");
header("X-Bar: Baz");
header_remove("X-Foo");
 ?>

      示例2
<?php 
header("X-Foo: Bar");
header("X-Bar: Baz");
header_remove();
 ?>

阅读全文 »

网络 函数 header 发送原生 HTTP 头

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<html><?php 
/* This will give an error. Note the output * above, which is before the header() call */
header('Location: http://www.example.com/');
exit;
?>

      示例2
<?php 
// 本示例演示了 "HTTP/" 的特殊例子,典型用法的最佳实践,包括:// 1. header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
//    (覆盖 http 状态消息,兼容还在使用 HTTP/1.0 的客户端)// 2. http_response_code(404);
 (使用默认消息)header("HTTP/1.1 404 Not Found");
?>

      示例3
<?php 
header("Location: http://www.example.com/");
 /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>

      示例4
<?php 
header('WWW-Authenticate: Negotiate');
header('WWW-Authenticate: NTLM', false);
?>

      示例5
<?php 
// 输出 PDF 文件header('Content-type: application/pdf');
// 名称为 downloaded.pdfheader('Content-Disposition: attachment;
 filename="downloaded.pdf"');
// 该 PDF 来源于 original.pdfreadfile('original.pdf');
?>

      示例6
<?php 
header("Cache-Control: no-cache, must-revalidate");
 // HTTP/1.1header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
 // 过去的日期?>

      示例7
<?php 
/* 根据当前请求所在的目录,重定向到不同的页面 */
$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>

阅读全文 »

网络 函数 headers_list 返回已发送的 HTTP 响应头(或准备发送的)

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
/* setcookie() 会自己添加一个响应头 */
setcookie('foo', 'bar');
/* 添加自定义的响应头 大多数客户端会主动忽略 */
header("X-Sample-Test: foo");
/* 响应中指定内容为明文 text */
header('Content-type: text/plain');
/* 所以会发送什么头呢? */
var_dump(headers_list());
?>

阅读全文 »

网络 函数 headers_sent 检测 HTTP 头是否已经发送

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
// 没有 HTTP 头就发送一个if (!headers_sent()) {
    header('Location: http://www.example.com/');
    exit;
}
// 使用 file 和 line 参数选项的例子// 注意 $filename 和 $linenum 用于下文中使用// 所以不要提前为它们赋值if (!headers_sent($filename, $linenum)) {
    header('Location: http://www.example.com/');
    exit;
// 很有可能在这里触发错误}
 else {
    echo "Headers already sent in $filename on line $linenum\n" .          "Cannot redirect, for now please click this <a " .          "href=\"http://www.example.com\">link</a> instead\n";
    exit;
}
?>

阅读全文 »

全部博文(1580)
集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。