mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
43 lines
1.9 KiB
HTML
43 lines
1.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Resource 资源类型</title>
|
|
</head>
|
|
<div id="layout">
|
|
<div id="layout-content"><div id="language.types.resource" class="sect1">
|
|
<h2 class="title">Resource 资源类型</h2>
|
|
|
|
<p class="para">
|
|
资源 <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>
|
|
是一种特殊变量,保存了到外部资源的一个引用。资源是通过专门的函数来建立和使用的。所有这些函数及其相应资源类型见<a href="resource.html" class="link">附录</a>。
|
|
</p>
|
|
|
|
<p class="para">
|
|
参见 <span class="function"><a href="get_resource_type.html" 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">Note</strong>:
|
|
<span class="simpara">
|
|
持久数据库连接比较特殊,它们<em class="emphasis">不会</em>被垃圾回收系统销毁。参见<a href="features.persistent-connections.html" class="link">数据库永久连接</a>一章。
|
|
</span>
|
|
</p></blockquote>
|
|
|
|
</div>
|
|
</div></div></div></body></html> |