惭愧,前几天翻看 unix编程艺术 才认识到,以前经常翻看 php手册 过程中经常见到的 supported protocols and wrappers 是多么让人喜爱 php的封装协议的语法仅支持 scheme://... php支持的协议有: file:// — 访问本地文件系统http:// — 访问 http(s) 网址ft
惭愧,前几天翻看 unix编程艺术 才认识到,以前经常翻看 php手册过程中经常见到的 supported protocols and wrappers 是多么让人喜爱
php的封装协议的语法仅支持 scheme://...php支持的协议有:
file:// — 访问本地文件系统http:// — 访问 http(s) 网址ftp:// — 访问 ftp(s) urlsphp:// — 访问各个输入/输出流(i/o streams)zlib:// — 压缩流data:// — 数据(rfc 2397)glob:// — 查找匹配的文件路径模式phar:// — php 归档ssh2:// — secure shell 2rar:// — rarogg:// — 音频流expect:// — 处理交互式的流
影响的函数有:
fopen() copy() fileexists() filesize() getimagesize() filegetcontents() fileput_contents() readfile() …
注意:
php://output 和 php://stdout 在 cli下是一模一样的即都会输出,因为他们都指向当前进程的stdout,但在 apache中 php://stdout没有输出,原因就是:
cli方式,所有输出都是指向标准输出即 终端
apache方式[sapi]方式,stdout是终端即apache的子进程的stdout,而 php://output则承载http进程的输出
2. fopen(./filename.ext) 和 fopen(/absolute_file_path/filename.ext) 可以认为是对fopen(file://.filename.ext)和fopen(file:///absolutefilepath/filename.ext)` 的简化
原文地址:php文件访问协议化, 感谢原作者分享。