Home  >  Article  >  php教程  >  php文件访问协议化

php文件访问协议化

WBOY
WBOYOriginal
2016-06-06 20:09:141372browse

惭愧,前几天翻看 unix编程艺术 才认识到,以前经常翻看 php手册 过程中经常见到的 Supported Protocols and Wrappers 是多么让人喜爱 php的封装协议的语法仅支持 scheme://... php支持的协议有: file:// — 访问本地文件系统http:// — 访问 HTTP(s) 网址ft

惭愧,前几天翻看 unix编程艺术 才认识到,以前经常翻看 php手册过程中经常见到的 Supported Protocols and Wrappers 是多么让人喜爱

  1. php的封装协议的语法仅支持 scheme://...
  2. php支持的协议有:

    <code class="language-text">file:// — 访问本地文件系统
    http:// — 访问 HTTP(s) 网址
    ftp:// — 访问 FTP(s) URLs
    php:// — 访问各个输入/输出流(I/O streams)
    zlib:// — 压缩流
    data:// — 数据(RFC 2397)
    glob:// — 查找匹配的文件路径模式
    phar:// — PHP 归档
    ssh2:// — Secure Shell 2
    rar:// — RAR
    ogg:// — 音频流
    expect:// — 处理交互式的流
    </code>
    1. 影响的函数有:

      fopen() copy() fileexists() filesize() getimagesize() filegetcontents() fileput_contents() readfile() …

    2. 注意:

      1. php://outputphp://stdoutCLI下是一模一样的即都会输出,因为他们都指向当前进程的STDOUT,但在 apachephp://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")` 的简化

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:缓存远程二维码图片到本地Next article:模版小例子