<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/language.types.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'language.types.resource.php',
    1 => 'Resource 资源类型',
    2 => 'Resource 资源类型',
  ),
  'up' => 
  array (
    0 => 'language.types.php',
    1 => '类型',
  ),
  'prev' => 
  array (
    0 => 'language.types.enumerations.php',
    1 => 'Enum 枚举',
  ),
  'next' => 
  array (
    0 => 'language.types.callable.php',
    1 => 'Callable',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'language/types/resource.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="language.types.resource" class="sect1">
 <h2 class="title">Resource 资源类型</h2>
  
 <p class="para">
  资源 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>
  是一种特殊变量，保存了到外部资源的一个引用。资源是通过专门的函数来建立和使用的。所有这些函数及其相应资源类型见<a href="resource.php" class="link">附录</a>。
 </p>
  
 <p class="para">
  参见 <span class="function"><a href="function.get-resource-type.php" class="function">get_resource_type()</a></span>。
 </p>

 <div class="sect2" id="language.types.resource.casting">
  <h3 class="title">转换为资源</h3>
  
  <p class="para">
   由于资源类型变量保存有为打开文件、数据库连接、图形画布区域等的特殊句柄，因此将其它类型的值转换为资源没有意义。
  </p>
 </div>

 <div class="sect2" id="language.types.resource.self-destruct">
  <h3 class="title">释放资源</h3>
  
  <p class="para">
   引用计数系统是 Zend 引擎的一部分，可以自动检测到一个资源不再被引用了（和 
   Java 一样）。这种情况下此资源使用的所有外部资源都会被垃圾回收系统释放。因此，很少需要手工释放内存。
  </p>

  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    持久数据库连接比较特殊，它们<em>不会</em>被垃圾回收系统销毁。参见<a href="features.persistent-connections.php" class="link">数据库永久连接</a>一章。
   </span>
  </p></blockquote>
  
 </div>
</div><?php manual_footer($setup); ?>