<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.basic.other.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'book.stream.php',
    1 => 'Stream',
    2 => 'Stream',
  ),
  'up' => 
  array (
    0 => 'refs.basic.other.php',
    1 => '其它基本扩展',
  ),
  'prev' => 
  array (
    0 => 'function.spl-object-id.php',
    1 => 'spl_object_id',
  ),
  'next' => 
  array (
    0 => 'stream.setup.php',
    1 => '安装/配置',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/stream/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.stream.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.stream" class="book">
 
 <h1 class="title">Stream</h1>

  <div id="intro.stream" class="preface">
   <h1 class="title">简介</h1>
   <p class="simpara">
    流是概括文件、网络、数据压缩和其它操作的方式，共享一组通用的函数和用途。在其的简单定义中，<code class="literal">stream</code>
    是表现可流动行为的 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> 对象。也就是说，它可以以线性的方式读写，并且可以 <span class="function"><a href="function.fseek.php" class="function">fseek()</a></span>
    到流中的任意位置。
   </p>
   <p class="simpara">
    <code class="literal">wrapper</code> 是附加代码，用于告诉流如何处理指定协议/编码。例如，<code class="literal">http</code> 封装协议知道如何将 URL
    转换为 <code class="literal">HTTP/1.0</code> 请求远程服务器上的文件。默认情况下，PHP 内置了很多封装协议（参阅 <a href="wrappers.php" class="xref">支持的协议和封装协议</a>），另外也可以直接从 PHP 脚本中使用 <span class="function"><a href="function.stream-wrapper-register.php" class="function">stream_wrapper_register()</a></span>
    或者直接从扩展中添加自定义封装协议。
    因为任何种类的封装协议都可以添加到 PHP 中，所以对它们可以做什么并没有限制。使用
    <span class="function"><a href="function.stream-get-wrappers.php" class="function">stream_get_wrappers()</a></span> 访问当前已注册封装协议列表。
   </p>
   <p class="para">
    流作为 <code class="parameter">scheme</code>://<code class="parameter">target</code> 引用
    <ul class="itemizedlist">
     <li class="listitem">
      <span class="simpara">
       <code class="parameter">scheme</code> (string) — 要使用的封装协议名称。示例为
       file、http、https、ftp、ftps、compress.zlib、compress.bz2 和 php。PHP 内置封装协议列表，参阅<a href="wrappers.php" class="xref">支持的协议和封装协议</a>。如果没有指定封装协议，函数使用默认值（通常是 <code class="literal">file</code>://）。
      </span>
     </li>
     <li class="listitem">
      <span class="simpara">
       <code class="parameter">target</code>——取决于要使用的封装协议。对于文件系统相关的流，这通常是所需文件的路径和文件名。对网络相关的流，这通常是主机名，通常跟着路径。再有，请参阅<a href="wrappers.php" class="xref">支持的协议和封装协议</a> 获取对流内置目标的描述。
      </span>
     </li>
    </ul>
   </p>
  </div>

 






 




 





 

 



  



 





 

 






 




 







 






 
<ul class="chunklist chunklist_book"><li><a href="stream.setup.php">安装/配置</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="stream.resources.php">Stream Classes</a></li></ul></li><li><a href="stream.constants.php">预定义常量</a></li><li><a href="stream.filters.php">Stream 过滤</a></li><li><a href="stream.contexts.php">Stream Contexts</a></li><li><a href="stream.errors.php">Stream Errors</a></li><li><a href="stream.examples.php">示例</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="stream.streamwrapper.example-1.php">示例类注册为流封装器</a></li></ul></li><li><a href="class.php-user-filter.php">php_user_filter</a> — The php_user_filter class<ul class="chunklist chunklist_book chunklist_children"><li><a href="php-user-filter.filter.php">php_user_filter::filter</a> — Called when applying the filter</li><li><a href="php-user-filter.onclose.php">php_user_filter::onClose</a> — Called when closing the filter</li><li><a href="php-user-filter.oncreate.php">php_user_filter::onCreate</a> — Called when creating the filter</li></ul></li><li><a href="class.streamwrapper.php">streamWrapper</a> — streamWrapper 类<ul class="chunklist chunklist_book chunklist_children"><li><a href="streamwrapper.construct.php">streamWrapper::__construct</a> — Constructs a new stream wrapper</li><li><a href="streamwrapper.destruct.php">streamWrapper::__destruct</a> — Destructs an existing stream wrapper</li><li><a href="streamwrapper.dir-closedir.php">streamWrapper::dir_closedir</a> — Close directory handle</li><li><a href="streamwrapper.dir-opendir.php">streamWrapper::dir_opendir</a> — Open directory handle</li><li><a href="streamwrapper.dir-readdir.php">streamWrapper::dir_readdir</a> — Read entry from directory handle</li><li><a href="streamwrapper.dir-rewinddir.php">streamWrapper::dir_rewinddir</a> — Rewind directory handle</li><li><a href="streamwrapper.mkdir.php">streamWrapper::mkdir</a> — Create a directory</li><li><a href="streamwrapper.rename.php">streamWrapper::rename</a> — Renames a file or directory</li><li><a href="streamwrapper.rmdir.php">streamWrapper::rmdir</a> — Removes a directory</li><li><a href="streamwrapper.stream-cast.php">streamWrapper::stream_cast</a> — Retrieve the underlying resource</li><li><a href="streamwrapper.stream-close.php">streamWrapper::stream_close</a> — Close a resource</li><li><a href="streamwrapper.stream-eof.php">streamWrapper::stream_eof</a> — Tests for end-of-file on a file pointer</li><li><a href="streamwrapper.stream-flush.php">streamWrapper::stream_flush</a> — Flushes the output</li><li><a href="streamwrapper.stream-lock.php">streamWrapper::stream_lock</a> — Advisory file locking</li><li><a href="streamwrapper.stream-metadata.php">streamWrapper::stream_metadata</a> — Change stream metadata</li><li><a href="streamwrapper.stream-open.php">streamWrapper::stream_open</a> — Opens file or URL</li><li><a href="streamwrapper.stream-read.php">streamWrapper::stream_read</a> — Read from stream</li><li><a href="streamwrapper.stream-seek.php">streamWrapper::stream_seek</a> — Seeks to specific location in a stream</li><li><a href="streamwrapper.stream-set-option.php">streamWrapper::stream_set_option</a> — Change stream options</li><li><a href="streamwrapper.stream-stat.php">streamWrapper::stream_stat</a> — Retrieve information about a file resource</li><li><a href="streamwrapper.stream-tell.php">streamWrapper::stream_tell</a> — Retrieve the current position of a stream</li><li><a href="streamwrapper.stream-truncate.php">streamWrapper::stream_truncate</a> — Truncate stream</li><li><a href="streamwrapper.stream-write.php">streamWrapper::stream_write</a> — Write to stream</li><li><a href="streamwrapper.unlink.php">streamWrapper::unlink</a> — Delete a file</li><li><a href="streamwrapper.url-stat.php">streamWrapper::url_stat</a> — Retrieve information about a file</li></ul></li><li><a href="ref.stream.php">Stream 函数</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.stream-bucket-append.php">stream_bucket_append</a> — Append bucket to brigade</li><li><a href="function.stream-bucket-make-writeable.php">stream_bucket_make_writeable</a> — Returns a bucket object from the brigade to operate on</li><li><a href="function.stream-bucket-new.php">stream_bucket_new</a> — Create a new bucket for use on the current stream</li><li><a href="function.stream-bucket-prepend.php">stream_bucket_prepend</a> — Prepend bucket to brigade</li><li><a href="function.stream-context-create.php">stream_context_create</a> — 创建资源流上下文</li><li><a href="function.stream-context-get-default.php">stream_context_get_default</a> — Retrieve the default stream context</li><li><a href="function.stream-context-get-options.php">stream_context_get_options</a> — 获取资源流/数据包/上下文的参数</li><li><a href="function.stream-context-get-params.php">stream_context_get_params</a> — Retrieves parameters from a context</li><li><a href="function.stream-context-set-default.php">stream_context_set_default</a> — Set the default stream context</li><li><a href="function.stream-context-set-option.php">stream_context_set_option</a> — 对资源流、数据包或者上下文设置参数</li><li><a href="function.stream-context-set-options.php">stream_context_set_options</a> — Sets options on the specified context</li><li><a href="function.stream-context-set-params.php">stream_context_set_params</a> — Set parameters for a stream/wrapper/context</li><li><a href="function.stream-copy-to-stream.php">stream_copy_to_stream</a> — Copies data from one stream to another</li><li><a href="function.stream-filter-append.php">stream_filter_append</a> — Attach a filter to a stream</li><li><a href="function.stream-filter-prepend.php">stream_filter_prepend</a> — Attach a filter to a stream</li><li><a href="function.stream-filter-register.php">stream_filter_register</a> — Register a user defined stream filter</li><li><a href="function.stream-filter-remove.php">stream_filter_remove</a> — 从资源流里移除某个过滤器</li><li><a href="function.stream-get-contents.php">stream_get_contents</a> — 读取资源流到一个字符串</li><li><a href="function.stream-get-filters.php">stream_get_filters</a> — 获取已注册的数据流过滤器列表</li><li><a href="function.stream-get-line.php">stream_get_line</a> — 从资源流里读取一行直到给定的定界符</li><li><a href="function.stream-get-meta-data.php">stream_get_meta_data</a> — 从流或文件指针中获取 header/meta 数据</li><li><a href="function.stream-get-transports.php">stream_get_transports</a> — 获取已注册的套接字传输协议列表</li><li><a href="function.stream-get-wrappers.php">stream_get_wrappers</a> — 获取已注册的流类型</li><li><a href="function.stream-is-local.php">stream_is_local</a> — Checks if a stream is a local stream</li><li><a href="function.stream-isatty.php">stream_isatty</a> — Check if a stream is a TTY</li><li><a href="function.stream-notification-callback.php">stream_notification_callback</a> — A callback function for the notification context parameter</li><li><a href="function.stream-register-wrapper.php">stream_register_wrapper</a> — 别名 stream_wrapper_register</li><li><a href="function.stream-resolve-include-path.php">stream_resolve_include_path</a> — Resolve filename against the include path</li><li><a href="function.stream-select.php">stream_select</a> — Runs the equivalent of the select() system call on the given
   arrays of streams with a timeout specified by seconds and microseconds</li><li><a href="function.stream-set-blocking.php">stream_set_blocking</a> — 为资源流设置阻塞或者阻塞模式</li><li><a href="function.stream-set-chunk-size.php">stream_set_chunk_size</a> — 设置资源流区块大小</li><li><a href="function.stream-set-read-buffer.php">stream_set_read_buffer</a> — Set read file buffering on the given stream</li><li><a href="function.stream-set-timeout.php">stream_set_timeout</a> — Set timeout period on a stream</li><li><a href="function.stream-set-write-buffer.php">stream_set_write_buffer</a> — Sets write file buffering on the given stream</li><li><a href="function.stream-socket-accept.php">stream_socket_accept</a> — 接受由 stream_socket_server 创建的套接字连接</li><li><a href="function.stream-socket-client.php">stream_socket_client</a> — Open Internet or Unix domain socket connection</li><li><a href="function.stream-socket-enable-crypto.php">stream_socket_enable_crypto</a> — Turns encryption on/off on an already connected socket</li><li><a href="function.stream-socket-get-name.php">stream_socket_get_name</a> — 获取本地或者远程的套接字名称</li><li><a href="function.stream-socket-pair.php">stream_socket_pair</a> — 创建一对完全一样的网络套接字连接流</li><li><a href="function.stream-socket-recvfrom.php">stream_socket_recvfrom</a> — Receives data from a socket, connected or not</li><li><a href="function.stream-socket-sendto.php">stream_socket_sendto</a> — Sends a message to a socket, whether it is connected or not</li><li><a href="function.stream-socket-server.php">stream_socket_server</a> — 创建 Internet 或 Unix 域服务器套接字</li><li><a href="function.stream-socket-shutdown.php">stream_socket_shutdown</a> — Shutdown a full-duplex connection</li><li><a href="function.stream-supports-lock.php">stream_supports_lock</a> — Tells whether the stream supports locking</li><li><a href="function.stream-wrapper-register.php">stream_wrapper_register</a> — 注册一个用 PHP 类实现的 URL 封装协议</li><li><a href="function.stream-wrapper-restore.php">stream_wrapper_restore</a> — Restores a previously unregistered built-in wrapper</li><li><a href="function.stream-wrapper-unregister.php">stream_wrapper_unregister</a> — Unregister a URL wrapper</li></ul></li></ul></div><?php manual_footer($setup); ?>