mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
96 lines
4.2 KiB
HTML
96 lines
4.2 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>检查接口是否已被定义</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.interface-exists" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">interface_exists</h1>
|
|
<p class="verinfo">(PHP 5 >= 5.0.2, PHP 7)</p><p class="refpurpose"><span class="refname">interface_exists</span> — <span class="dc-title">检查接口是否已被定义</span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.interface-exists-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>interface_exists</strong></span>
|
|
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$interface_name</code></span>
|
|
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$autoload</code><span class="initializer"> = true</span></span>
|
|
] ) : <span class="type">bool</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
检查接口是否已被定义。
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.interface-exists-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">interface_name</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
接口名。
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">autoload</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
默认是否调用 <a href="language.oop5.autoload.html" class="link">__autoload</a>。
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.interface-exists-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
本函数在由 <code class="parameter">interface_name</code>
|
|
给出的接口已定义时返回 <strong><code>TRUE</code></strong>,否则返回 <strong><code>FALSE</code></strong>。
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.interface-exists-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-6146">
|
|
<p><strong>Example #1 <span class="function"><strong>interface_exists()</strong></span> 例子</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// 在尝试使用前先检查接口是否存在<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">interface_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'MyInterface'</span><span style="color: #007700">)) {<br /> class </span><span style="color: #0000BB">MyClass </span><span style="color: #007700">implements </span><span style="color: #0000BB">MyInterface<br /> </span><span style="color: #007700">{<br /> </span><span style="color: #FF8000">// Methods<br /> </span><span style="color: #007700">}<br />}<br /><br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.interface-exists-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="get_declared_interfaces.html" class="function" rel="rdfs-seeAlso">get_declared_interfaces()</a> - 返回一个数组包含所有已声明的接口</span></li>
|
|
<li class="member"><span class="function"><a href="class_implements.html" class="function" rel="rdfs-seeAlso">class_implements()</a> - 返回指定的类实现的所有接口。</span></li>
|
|
<li class="member"><span class="function"><a href="class_exists.html" class="function" rel="rdfs-seeAlso">class_exists()</a> - 检查类是否已定义</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |