mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
129 lines
5.5 KiB
HTML
129 lines
5.5 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.method-exists" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">method_exists</h1>
|
|
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">method_exists</span> — <span class="dc-title">检查类的方法是否存在</span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.method-exists-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>method_exists</strong></span>
|
|
( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$object</code></span>
|
|
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$method_name</code></span>
|
|
) : <span class="type">bool</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
检查类的方法是否存在于指定的 <code class="parameter">object</code>中。
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.method-exists-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">object</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
对象示例或者类名。
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">method_name</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
方法名。
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.method-exists-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
如果 <code class="parameter">method_name</code>
|
|
所指的方法在 <code class="parameter">object</code>
|
|
所指的对象类中已定义,则返回 <strong><code>TRUE</code></strong>,否则返回 <strong><code>FALSE</code></strong>。
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 notes" id="refsect1-function.method-exists-notes">
|
|
<h3 class="title">注释</h3>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">如果此类不是已知类,使用此函数会使用任何已注册的
|
|
<a href="language.oop5.autoload.html" class="link">autoloader</a>。</p></p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.method-exists-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-6151">
|
|
<p><strong>Example #1 <span class="function"><strong>method_exists()</strong></span> 例子</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$directory </span><span style="color: #007700">= new </span><span style="color: #0000BB">Directory</span><span style="color: #007700">(</span><span style="color: #DD0000">'.'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">method_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$directory</span><span style="color: #007700">,</span><span style="color: #DD0000">'read'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程会输出:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
bool(true)
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="example" id="example-6152">
|
|
<p><strong>Example #2 Static <span class="function"><strong>method_exists()</strong></span> 例子
|
|
</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">method_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'Directory'</span><span style="color: #007700">,</span><span style="color: #DD0000">'read'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程会输出:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
bool(true)
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.method-exists-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="function_exists.html" class="function" rel="rdfs-seeAlso">function_exists()</a> - 如果给定的函数已经被定义就返回 TRUE</span></li>
|
|
<li class="member"><span class="function"><a href="is_callable.html" class="function" rel="rdfs-seeAlso">is_callable()</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> |