PHP http://
简介
http://和https://包装器通过 HTTP 协议启用对资源和文件的只读访问。当处理基于虚拟名称的主机时,host:标头也会与user_agent一起发送(如果在 php.ini 中配置)。
http 标头信息存储在$http_response_header变量中。必须处理这些标头才能借助from:标头了解文档来源的资源 URL。
仅当在 php.ini 设置中启用了openssl扩展时才支持 HTTPS。HTTP 和 HTTPS 连接都是只读的,不支持写或复制文件。
用法
文件名的不同可能表示如下 −
https:// http://example.com https://?name='Ram'&age=20 https://example.com http://username:password@abc.com
示例
<?php
$url = 'https://tutorialspoint.com/php7/php7_closure_call.htm';
if (!$fp = fopen($url, 'r')) {
trigger_error("Unable to open URL ($url)", E_USER_ERROR);
}
$meta = stream_get_meta_data($fp);
print_r($meta);
?>以上脚本从 http URL 读取标头元数据
Array( [crypto] => Array( [protocol] => TLSv1.2 [cipher_name] => ECDHE-RSA-AES128-GCM-SHA256 [cipher_bits] => 128 [cipher_version] => TLSv1/SSLv3 ) [timed_out] => [blocked] => 1 [eof] => [wrapper_data] => Array( [0] => HTTP/1.0 200 OK [1] => Age: 1310067 [2] => Cache-Control: max-age=2592000 [3] => Content-Type: text/html; charset=UTF-8 [4] => Date: Mon, 14 Sep 2020 17:15:36 GMT [5] => Expires: Wed, 14 Oct 2020 17:15:36 GMT [6] => Last-Modified: Sun, 30 Aug 2020 13:21:09 GMT [7] => Server: ECS (nag/99AA) [8] => Strict-Transport-Security: max-age=63072000; includeSubdomains [9] => Vary: Accept-Encoding [10] => X-Cache: HIT [11] => X-Content-Type-Options: nosniff [12] => X-Frame-Options: SAMEORIGIN [13] => X-XSS-Protection: 1; mode=block [14] => Content-Length: 24102 [15] => Connection: close ) [wrapper_type] => http [stream_type] => tcp_socket/ssl [mode] => r [unread_bytes] => 0 [seekable] => [uri] => https://tutorialspoint.com/php7/php7_closure_call.htm )
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP