<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.info.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.get-resources.php',
    1 => 'get_resources',
    2 => 'Returns active resources',
  ),
  'up' => 
  array (
    0 => 'ref.info.php',
    1 => 'PHP 选项/信息 函数',
  ),
  'prev' => 
  array (
    0 => 'function.get-required-files.php',
    1 => 'get_required_files',
  ),
  'next' => 
  array (
    0 => 'function.getenv.php',
    1 => 'getenv',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/info/functions/get-resources.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.get-resources" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">get_resources</h1>
  <p class="verinfo">(PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">get_resources</span> &mdash; <span class="dc-title">Returns active resources</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.get-resources-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>get_resources</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$type</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Returns an array of all currently active <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>s, optionally
   filtered by resource type.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    This function is meant for debugging and testing purposes. It is not supposed
    to be used in production environments, especially not to access or even manipulate
    resources which are normally not accessible (e.g. the underlying stream resource
    of <span class="classname"><a href="class.splfileobject.php" class="classname">SplFileObject</a></span> instances).
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.get-resources-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">type</code></dt>
     <dd>
      <p class="para">
       If defined, this will cause <span class="function"><strong>get_resources()</strong></span> to only
       return resources of the given type.
       <a href="resource.php" class="link">A list of resource types is available.</a>
      </p>
      <p class="para">
       If the <span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="literal">Unknown</code> is provided as
       the type, then only resources that are of an unknown type will be
       returned.
      </p>
      <p class="para">
       If omitted, all resources will be returned.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.get-resources-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of currently active resources, indexed by
   resource number.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.get-resources-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">type</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.get-resources-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 Unfiltered <span class="function"><strong>get_resources()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">tmpfile</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_resources</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(1) {
  [1]=&gt;
  resource(1) of type (stream)
}</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>示例 #2 Filtered <span class="function"><strong>get_resources()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">tmpfile</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_resources</span><span style="color: #007700">(</span><span style="color: #DD0000">'stream'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_resources</span><span style="color: #007700">(</span><span style="color: #DD0000">'curl'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(1) {
  [1]=&gt;
  resource(1) of type (stream)
}
array(0) {
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.get-resources-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.get-loaded-extensions.php" class="function" rel="rdfs-seeAlso">get_loaded_extensions()</a> - 返回所有编译并加载模块名的 array</span></li>
    <li><span class="function"><a href="function.get-defined-constants.php" class="function" rel="rdfs-seeAlso">get_defined_constants()</a> - 返回所有常量的关联数组，键是常量名，值是常量值</span></li>
    <li><span class="function"><a href="function.get-defined-functions.php" class="function" rel="rdfs-seeAlso">get_defined_functions()</a> - 返回所有已定义函数的数组</span></li>
    <li><span class="function"><a href="function.get-defined-vars.php" class="function" rel="rdfs-seeAlso">get_defined_vars()</a> - 返回由所有已定义变量所组成的数组</span></li>
   </ul>
  </p>
 </div>


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