mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
118 lines
8.9 KiB
HTML
118 lines
8.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>Call a static method</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.forward-static-call" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">forward_static_call</h1>
|
|
<p class="verinfo">(PHP 5 >= 5.3.0, PHP 7)</p><p class="refpurpose"><span class="refname">forward_static_call</span> — <span class="dc-title">Call a static method</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.forward-static-call-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>forward_static_call</strong></span>
|
|
( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$function</code></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">$parameter</code></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">$...</code></span>
|
|
]] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Calls a user defined function or method given by the <code class="parameter">function</code>
|
|
parameter, with the following arguments. This function must be called within a method
|
|
context, it can't be used outside a class.
|
|
It uses the <a href="language.oop5.late_static_bindings.html" class="link">late static
|
|
binding</a>.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.forward-static-call-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">function</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The function or method to be called. This parameter may be an array,
|
|
with the name of the class, and the method, or a string, with a function
|
|
name.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">parameter</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
Zero or more parameters to be passed to the function.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.forward-static-call-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns the function result, or <strong><code>FALSE</code></strong> on error.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.forward-static-call-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-6197">
|
|
<p><strong>Example #1 <span class="function"><strong>forward_static_call()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">A<br /></span><span style="color: #007700">{<br /> const </span><span style="color: #0000BB">NAME </span><span style="color: #007700">= </span><span style="color: #DD0000">'A'</span><span style="color: #007700">;<br /> public static function </span><span style="color: #0000BB">test</span><span style="color: #007700">() {<br /> </span><span style="color: #0000BB">$args </span><span style="color: #007700">= </span><span style="color: #0000BB">func_get_args</span><span style="color: #007700">();<br /> echo static::</span><span style="color: #0000BB">NAME</span><span style="color: #007700">, </span><span style="color: #DD0000">" "</span><span style="color: #007700">.</span><span style="color: #0000BB">join</span><span style="color: #007700">(</span><span style="color: #DD0000">','</span><span style="color: #007700">, </span><span style="color: #0000BB">$args</span><span style="color: #007700">).</span><span style="color: #DD0000">" \n"</span><span style="color: #007700">;<br /> }<br />}<br /><br />class </span><span style="color: #0000BB">B </span><span style="color: #007700">extends </span><span style="color: #0000BB">A<br /></span><span style="color: #007700">{<br /> const </span><span style="color: #0000BB">NAME </span><span style="color: #007700">= </span><span style="color: #DD0000">'B'</span><span style="color: #007700">;<br /><br /> public static function </span><span style="color: #0000BB">test</span><span style="color: #007700">() {<br /> echo </span><span style="color: #0000BB">self</span><span style="color: #007700">::</span><span style="color: #0000BB">NAME</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /> </span><span style="color: #0000BB">forward_static_call</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'A'</span><span style="color: #007700">, </span><span style="color: #DD0000">'test'</span><span style="color: #007700">), </span><span style="color: #DD0000">'more'</span><span style="color: #007700">, </span><span style="color: #DD0000">'args'</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">forward_static_call</span><span style="color: #007700">( </span><span style="color: #DD0000">'test'</span><span style="color: #007700">, </span><span style="color: #DD0000">'other'</span><span style="color: #007700">, </span><span style="color: #DD0000">'args'</span><span style="color: #007700">);<br /> }<br />}<br /><br /></span><span style="color: #0000BB">B</span><span style="color: #007700">::</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">);<br /><br />function </span><span style="color: #0000BB">test</span><span style="color: #007700">() {<br /> </span><span style="color: #0000BB">$args </span><span style="color: #007700">= </span><span style="color: #0000BB">func_get_args</span><span style="color: #007700">();<br /> echo </span><span style="color: #DD0000">"C "</span><span style="color: #007700">.</span><span style="color: #0000BB">join</span><span style="color: #007700">(</span><span style="color: #DD0000">','</span><span style="color: #007700">, </span><span style="color: #0000BB">$args</span><span style="color: #007700">).</span><span style="color: #DD0000">" \n"</span><span style="color: #007700">;<br /> }<br /><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>
|
|
B
|
|
B more,args
|
|
C other,args
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.forward-static-call-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="forward_static_call_array.html" class="function" rel="rdfs-seeAlso">forward_static_call_array()</a> - Call a static method and pass the arguments as array</span></li>
|
|
<li class="member"><span class="function"><a href="call_user_func_array.html" class="function" rel="rdfs-seeAlso">call_user_func_array()</a> - 调用回调函数,并把一个数组参数作为回调函数的参数</span></li>
|
|
<li class="member"><span class="function"><a href="call_user_func.html" class="function" rel="rdfs-seeAlso">call_user_func()</a> - 把第一个参数作为回调函数调用</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"><a href="language.pseudo-types.html#language.types.callback" class="link">callback</a> 类型的信息</li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |