PHP - Manual手册 - Appendices附录 - List of Supported Protocols/Wrappers支持的协议/封装协议列表 - HTTP and HTTPS
2008-07-11 13:55
826 查看
PHP - Manual手册 - Appendices附录 - List of Supported Protocols/Wrappers支持的协议/封装协议列表 - HTTP and HTTPS
HTTP and HTTPS
PHP 4, PHP 5, PHP 6. https:// since PHP 4.3.0http://example.com
http://example.com/file.php?var1=val1&var2=val2
http://user:password@example.com
https://example.com
https://example.com/file.php?var1=val1&var2=val2
https://user:password@example.com
Allows read-only access to files/resources via HTTP 1.0, using the HTTP GET method. A Host: header is sent with the request to handle name-based virtual hosts. If you have configured a user_agent string using your ini file or the stream context, it will also be included in the request.
Warning
When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To work around this, the value of error_reporting should be lowered to a level that does not include warnings. PHP 4.3.7 and higher can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning. When using fsockopen() to create an ssl:// socket, the developer is responsible for detecting and suppressing this warning.
Redirects have been supported since PHP 4.0.5; if you are using an earlier version you will need to include trailing slashes in your URLs. If it's important to know the URL of the resource where your document came from (after all redirects have been processed), you'll need to process the series of response headers returned by the stream.
<?php
$url = 'http://www.example.com/redirecting_page.php';
$fp = fopen($url, 'r');
/* Prior to PHP 4.3.0 use $http_response_header
instead of stream_get_meta_data() */
$meta_data = stream_get_meta_data($fp);
foreach($meta_data['wrapper_data'] as $response) {
/* Were we redirected? */
if (substr(strtolower($response), 0, 10) == 'location: ') {
/* update $url with where we were redirected to */
$url = substr($response, 18);
}
}
?>
The stream allows access to the body of the resource; the headers are stored in the $http_response_header variable. Since PHP 4.3.0, the headers are available using stream_get_meta_data().
HTTP connections are read-only; you cannot write data or copy files to an HTTP resource.
Note: HTTPS is supported starting from PHP 4.3.0, if you have compiled in support for OpenSSL.
Attribute | Supported |
---|---|
Restricted by allow_url_fopen | Yes |
Allows Reading | Yes |
Allows Writing | No |
Allows Appending | No |
Allows Simultaneous Reading and Writing | N/A |
Supports stat() | No |
Supports unlink() | No |
Supports rename() | No |
Supports mkdir() | No |
Supports rmdir() | No |
Example #1 Sending custom headers with an HTTP request
<?php
ini_set('user_agent', "PHP/r/nX-MyCustomHeader: Foo");
$fp = fopen('http://www.example.com/index.php', 'r');
?>
Results in the following request being sent:
GET /index.php HTTP/1.0 Host: www.example.com User-Agent: PHP X-MyCustomHeader: Foo
[PHP - Manual手册 - Appendices附录 - List of Supported Protocols/Wrappers支持的协议/封装协议列表 - HTTP and HTTPS - 文档]
http://www.php.net/manual/en/wrappers.http.php
[PHP - 官方网站]
http://www.php.net/[PHP - 关键词]
phppdt
[PHP - 相关论坛]
http://php.board.newsmth.net/http://homepage.bdwm.net/
http://forum.csdn.net/SList/PHP/
[PHP - 下载]
AppServ 2.5.9, http://www.appservnetwork.com/Zend Optimizer 3.3.0a, http://www.zend.com/products/zend_optimizer
phpMyAdmin 2.11.2, http://www.phpmyadmin.net/home_page/index.php
Zend Core 2.5.0, http://www.zend.com/products/zend_core
Zend Platform 3.0.3, http://www.zend.com/products/zend_platform
PHP 5.2.5, http://www.php.net/releases/5_2_5.php
Zend Studio 5.5, http://www.zend.com/products/zend_studio
Zend Guard 5.0, http://www.zend.com/products/zend_guard PDT Project 1.0.3, http://www.eclipse.org/pdt/
[PHP - Manual手册]
http://www.php.net/manual/[PHP - XOOPS]
http://xoops.org.cn/[PHP - phpBB]
http://www.phpbbchina.com/[PHP - Manual手册]
file_exists检查文件或目录是否存在, http://www.php.net/manual/zh/function.file-exists.php[PHP - Manual手册 - 下载]
http://www.php.net/download-docs.php[PHP - Manual手册 - 语言参考 - 类型]
字符串转换为数值, http://www.php.net/manual/zh/language.types.string.php#language.types.string.conversion[PHP - Manual手册 - Language Reference语言参考 - Variables变量]
Variable scope变量可见性, http://www.php.net/manual/en/language.variables.scope.php[PHP - Manual手册 - 第 13 章 常量]
魔术常量, http://www.php.net/manual/zh/language.constants.predefined.php[PHP - Manual手册 - 语言参考 - 运算符]
错误控制运算符, http://www.php.net/manual/zh/language.operators.errorcontrol.php位运算符, http://www.php.net/manual/zh/language.operators.bitwise.php
[PHP - Manual手册 - 语言参考 - 控制结构]
foreach遍历数组, http://www.php.net/manual/zh/control-structures.foreach.php[PHP - Manual手册 - 语言参考 - 类与对象(PHP 5)]
Object cloning对象克隆, http://www.php.net/manual/zh/language.oop5.cloning.phpClass Abstraction类抽象, http://www.php.net/manual/zh/language.oop5.abstract.php
[PHP - Manual手册 - 第20章 异常处理]
概述, http://www.php.net/manual/zh/language.exceptions.php用异常处理php改进流程
[PHP - Manual手册 - 第21章 引用的解释]
引用返回, http://www.php.net/manual/zh/language.references.return.php[PHP - Manual手册 - 特点 - PHP 的命令行模式]
PHP 的命令行模式, http://www.php.net/manual/zh/features.commandline.php表 43.2. CLI 专用常量, http://www.php.net/manual/zh/features.commandline.php#id2715646
[PHP - Manual手册 - V. Array 数组函数]
计算数组的交集, http://www.php.net/manual/zh/function.array-intersect.phparray_merge合并一个或多个数组, http://www.php.net/manual/zh/function.array-merge.php
reset将数组的内部指针指向第一个单元, http://www.php.net/manual/zh/function.reset.php
[PHP - Manual手册 - XVIII. CURL, 客户端URL库函数]
概述, http://www.php.net/manual/zh/ref.curl.phpcurl_setopt设置cURL传输的选项, http://www.php.net/manual/zh/function.curl-setopt.php
[PHP - Manual手册 - XXII. Date/Time 日期/时间函数]
date格式化一个本地时间/日期, http://www.php.net/manual/zh/function.date.php[PHP - Manual手册 - Function Reference函数参考 - File System Related Extensions文件系统相关扩展 - Directories目录 - Directory Functions目录函数]
scandir列出指定路径中的文件和目录, http://www.php.net/manual/en/function.scandir.php[PHP - Manual手册 - Function Reference函数参考 - File System Related Extensions文件系统相关扩展 - Filesystem文件系统 - Filesystem Functions文件系统函数]
fscanf从文件中格式化输入, http://www.php.net/manual/en/function.fscanf.phpglob按模式获取文件名, http://www.php.net/manual/en/function.glob.php
[PHP - Manual手册 - XXXIII. Error Handling and Logging Functions错误处理和日志函数]
概述, http://www.php.net/manual/zh/ref.errorfunc.php [PHP - Manual手册 - 函数参考 - Filesystem 文件系统函数]
is_uploaded_file判断文件是否是通过 HTTP POST 上传的, http://www.php.net/manual/zh/function.is-uploaded-file.php fgetcsv从文件指针中读入一行并解析 CSV 字段, http://www.php.net/manual/zh/function.fgetcsv.php
is_dir判断给定文件名是否是一个目录, http://www.php.net/manual/zh/function.is-dir.php is_file判断给定文件名是否为一个正常的文件, http://www.php.net/manual/zh/function.is-file.php
[PHP - Manual手册 - XLVII. Function Handling Functions函数管理函数]
register_shutdown_function注册一个脚本结束时调用的函数, http://www.php.net/manual/zh/function.register-shutdown-function.php[PHP - Manual手册 - XC. Miscellaneous Functions杂项函数]
sleep延迟执行, http://www.php.net/manual/zh/ref.misc.phpuniqid生成唯一ID, http://www.php.net/manual/zh/function.uniqid.php
[PHP - Manual手册 - Function Reference函数参考 - Database Extensions数据库扩展 - Vendor Specific Database Extensions特定提供商数据库扩展 - MySQL - MySQL Functions - MySQL函数]
mysql_real_escape_string转义SQL语句中使用的字符串中的特殊字符,并考虑到连接的当前字符集, http://www.php.net/manual/en/function.mysql-real-escape-string.php
[PHP - Manual手册 - CII. Network Functions网络函数]
setcookie发送一个cookie, http://www.php.net/manual/zh/function.setcookie.php[PHP - Manual手册 - 函数参考 - PHP Options&Information - PHP选项与信息]
extension_loaded查询是否加载指定的扩展, http://www.php.net/manual/zh/function.extension-loaded.phpdl运行时加载PHP扩展, http://www.php.net/manual/zh/function.dl.php
[PHP - Manual手册 - CXXVII. PostgreSQL 数据库函数]
pg_insert将数组插入到表中, http://www.php.net/manual/zh/index.php[PHP - Manual手册 - CXXX. Program Execution Functions程序调用函数]
proc_open执行命令并打开用于输入输出的文件指针, http://www.php.net/manual/zh/function.proc-open.php[PHP - Manual手册 - CXLIX. Session 会话处理函数]
session.save_path 定义了传递给存储处理器的参数, http://www.php.net/manual/zh/ref.session.php#ini.session.save-pathsession.use_only_cookies指定是否在客户端仅仅使用 cookie 来存放会话 ID, http://www.php.net/manual/zh/ref.session.php#ini.session.use-only-cookies
[PHP - Manual手册 - 函数参考 - SOAP Functions - SOAP函数]
soap.wsdl_cache_enabled启用或禁用WSDL缓存功能, http://www.php.net/manual/zh/ref.soap.php#ini.soap.wsdl-cache-enabledSOAP configuration options missing documentation文档中丢失SOAP配置选项, http://bugs.php.net/bug.php?id=38644
[PHP - Manual手册 - Function Reference函数参考 - Text Processing文本处理 - Strings字符串 - String Functions字符串函数]
str_pad使用另一个字符串将一个字符串填充到指定长度, http://www.php.net/manual/zh/function.str-pad.phpstrpos查找一个字符串第一次出现的位置, http://www.php.net/manual/zh/function.strpos.php
substr返回字符串中的一部分, http://www.php.net/manual/zh/function.substr.php
str_replace用替换字符串替换所有出现的搜索字符串, http://www.php.net/manual/zh/function.str-replace.php explode使用一个字符串分割另一个字符串, http://www.php.net/manual/zh/function.explode.php strip_tags字符串中去除HTML和PHP标记, http://www.php.net/manual/en/function.strip-tags.php
[PHP - Manual手册 - Function Reference函数参考 - Other Basic Extensions其他基本扩展 - Tidy]
Tidy Functions - Tidy函数, http://www.php.net/manual/en/ref.tidy.php[PHP - Manual手册 - CLXVII. Tokenizer Functions解析器代号函数]
Tokenizer Functions解析器代号函数, http://www.php.net/manual/zh/ref.tokenizer.phptoken_get_all把给定源代码分解成解析器代号, http://www.php.net/manual/zh/function.token-get-all.php
[PHP - Manual手册 - CLXIX. URL 函数]
概述, http://www.php.net/manual/zh/ref.url.php[PHP - Manual手册 - Function Reference函数参考 - Variable and Type Related Extensions变量和类型相关扩展 - Arrays数组 - Array Functions数组函数]
ksort对数组按照键名排序, http://www.php.net/manual/en/function.ksort.php[PHP - Manual手册 - Function Reference函数参考 - Variable and Type Related Extensions变量和类型相关扩展 - Variable handling变量操作 - Variable handling Functions变量操作函数]
is_numeric检测变量是否为数字或数字字符串, http://www.php.net/manual/en/function.is-numeric.phpserialize产生一个可存储的值的表示, http://www.php.net/manual/zh/function.serialize.php settype设置变量的类型, http://www.php.net/manual/zh/function.settype.php
[PHP - Manual手册 - CLXXXVII. Zip File Functions - Zip文件压缩函数]
概述, http://www.php.net/manual/zh/ref.zip.php[PHP - Manual手册 - Appendices附录 - php.ini directives - php.ini配置选项 - Description of core php.ini directives描述核心php.ini配置选项]
register_globals 决定是否将 EGPCS(Environment,GET,POST,Cookie,Server)变量注册为全局变量, http://www.php.net/manual/en/ini.core.php#ini.register-globalsshort_open_tag决定是否允许使用PHP代码开始标志的缩写形式, http://www.php.net/manual/zh/ini.core.php#ini.short-open-tag php.ini 核心配置选项说明 - file_uploads, http://www.php.net/manual/zh/ini.core.php#ini.file-uploads
[PHP - Manual手册 - 附录 L. 保留字列表]
服务器变量:$_SERVER, http://www.php.net/manual/zh/reserved.variables.php#reserved.variables.server[PHP - Manual手册 - Appendices附录 - List of Supported Protocols/Wrappers支持的协议/封装协议列表]
HTTP and HTTPS, http://www.php.net/manual/en/wrappers.http.php[PHP - Manual手册 - 附录 Q. PHP 类型比较表]
表 Q.2. 用 == 进行松散比较, http://www.php.net/manual/zh/types.comparisons.php#id9240444 [PHP - 应用实例]
语法着色, php.exe -s "%1" > "%1.html"移除SimpleXML对象中的子对象
算24点
相关文章推荐
- PHP - Manual手册 - Appendices附录 - php.ini directives - php.ini配置选项 - Description of core php.ini directives描述核心php.ini配置选项 - regis
- PHP 手册 语言参考 支持的协议和封装协议
- PHP 支持的协议/封装协议列表
- PHP - Manual手册 - 附录 L. 保留字列表 - 服务器变量:$_SERVER
- 生产环境常见的HTTP状态码列表(List of HTTP status codes)
- PHP - Manual手册 - 附录 H. php.ini 配置选项 - short_open_tag决定是否允许使用PHP代码开始标志的缩写形式
- 复习PHP-语言参考-支持的协议和封装协议
- PHP - Manual手册 - 附录 - php.ini 配置选项 - php.ini 核心配置选项说明 - file_uploads
- PHP基础之PHP支持的协议和封装协议
- php支持的协议和封装协议
- List of I++ predefined errors / I++协议的预定义错误列表
- PHP - Manual手册 - 附录 Q. PHP 类型比较表 - 表 Q.2. 用 == 进行松散比较
- php支持的协议和封装协议和三种CLI常量:STDIN,STDOUT,STDERR
- 关于php支持的协议与封装协议总结(推荐)
- php入门十八之支持的协议和封装协议
- PHP - Manual手册 - XL. Filesystem 文件系统函数 - is_uploaded_file判断文件是否是通过 HTTP POST 上传的
- PHP - Manual手册 - 函数参考 - Tokenizer Functions解析器代号函数
- Android中的Webview加载URL支持其他协议Protocols
- nginx搭建支持http和rtmp协议的流媒体服务器之二
- PHP5.5中新增foreach() 循环支持标量迭代键-foreach+list和array_column用法