<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.stream.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.stream-get-line.php',
    1 => 'stream_get_line',
    2 => '从资源流里读取一行直到给定的定界符',
  ),
  'up' => 
  array (
    0 => 'ref.stream.php',
    1 => 'Stream 函数',
  ),
  'prev' => 
  array (
    0 => 'function.stream-get-filters.php',
    1 => 'stream_get_filters',
  ),
  'next' => 
  array (
    0 => 'function.stream-get-meta-data.php',
    1 => 'stream_get_meta_data',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/stream/functions/stream-get-line.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stream-get-line" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_get_line</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_get_line</span> &mdash; <span class="dc-title">从资源流里读取一行直到给定的定界符</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-get-line-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_get_line</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$stream</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$length</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$ending</code><span class="initializer"> = &quot;&quot;</span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
      从给定的资源流里读取一行。
  </p>
  <p class="para">
   当读取到 <code class="parameter">length</code> 个字节数就结束，或者当在读取的非空字符串中发现  <code class="parameter">ending</code> （<em>不</em>包含到返回值里）也结束，又或者遇到了 <abbr title="End Of File">EOF</abbr> 也结束（总之以上条件中哪个先出现就以哪个为准）。
  </p>
  <p class="para">
   这个函数与 <span class="function"><a href="function.fgets.php" class="function">fgets()</a></span> 几乎是相同的，唯一的区别是在这个函数里面允许指定行尾的定界符，而不是使用标准的 \n， \r 还有 \r\n ，并且返回值中<em>不</em>包含定界符。（翻译注：也可以把 \n 等作为定界符传入 <code class="parameter">ending</code> ）
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-get-line-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stream</code></dt>
     <dd>
      <p class="para">
       一个有效的文件句柄。
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       需要从句柄中读取的最大字节数。不支持负值。
       <code class="literal">0</code> 表示默认的套接字块大小（socket chunk size），即
       <code class="literal">8192</code> 字节。
      </p>
     </dd>
    
    
     <dt><code class="parameter">ending</code></dt>
     <dd>
      <p class="para">
       可选参数，字符串定界符。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-get-line-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个字符串，该字符串的内容根据 <code class="parameter">length</code>
   字节数从 <code class="parameter">stream</code> 里读取， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>

  
 <div class="refsect1 seealso" id="refsect1-function.stream-get-line-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.fread.php" class="function" rel="rdfs-seeAlso">fread()</a> - 读取文件（可安全用于二进制文件）</span></li>
   <li><span class="function"><a href="function.fgets.php" class="function" rel="rdfs-seeAlso">fgets()</a> - 从文件指针中读取一行</span></li>
   <li><span class="function"><a href="function.fgetc.php" class="function" rel="rdfs-seeAlso">fgetc()</a> - 从文件指针中读取字符</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>