上下文与支持的协议
# 上下文选项
PHP 提供了多种上下文选项和参数,可用于所有的文件系统或数据流封装协议。上下文(Context)由 stream_context_create() (opens new window) 创建。选项可通过 stream_context_set_option() (opens new window) 设置,参数可通过 stream_context_set_params() (opens new window) 设置。
目录如下
- 套接字上下文选项 (opens new window) — 套接字上下文选项列表
- HTTP context 选项 (opens new window) — HTTP context 的选项列表
- FTP context options (opens new window) — FTP context option listing
- SSL 上下文选项 (opens new window) — SSL 上下文选项清单
- CURL context options (opens new window) — CURL 上下文选项列表
- Phar 上下文(context)选项 (opens new window) — Phar 上下文(context)选项列表
- MongoDB context options (opens new window) — MongoDB context option listing
- Context 参数 (opens new window) — Context 参数列表
- Zip context options (opens new window) — Zip context option listing
# 支持的协议
PHP 带有很多内置 URL 风格的封装协议,可用于类似 fopen() (opens new window)、 copy() (opens new window)、 file_exists() (opens new window) 和 filesize() (opens new window) 的文件系统函数。 除了这些封装协议,还能通过 stream_wrapper_register() (opens new window) 来注册自定义的封装协议。
- file:// (opens new window) — 访问本地文件系统
- http:// (opens new window) — 访问 HTTP(s) 网址
- ftp:// (opens new window) — 访问 FTP(s) URLs
- php:// (opens new window) — 访问各个输入/输出流(I/O streams)
- zlib:// (opens new window) — 压缩流
- data:// (opens new window) — 数据(RFC 2397)
- glob:// (opens new window) — 查找匹配的文件路径模式
- phar:// (opens new window) — PHP 归档
- ssh2:// (opens new window) — Secure Shell 2
- rar:// (opens new window) — RAR
- ogg:// (opens new window) — 音频流
- expect:// (opens new window) — 处理交互式的流
编辑 (opens new window)
上次更新: 2021/05/08, 22:02:42