首页 >后端开发 >php教程 >PHP Callback 回调类型 js callback call back to asynccallbac

PHP Callback 回调类型 js callback call back to asynccallbac

WBOY
WBOY原创
2016-07-29 08:54:101104浏览

composerautoload 的时候发现他用 spl_autoload_register 注册了一个类 class 进去。。

明明记得是要传进去一个待注册的 autoload function 队列,查了查文档才发现关于 Callback 回调类型理解有误

看文档里面关于 Callback 回调类型的示例:

<code><span>// Type 1: Simple callback</span>
call_user_func(<span>'my_callback_function'</span>); 

<span>// Type 2: Static class method call</span>
call_user_func(<span>array</span>(<span>'MyClass'</span>, <span>'myCallbackMethod'</span>)); 

<span>// Type 3: Object method call</span><span>$obj</span> = <span>new</span> MyClass();
call_user_func(<span>array</span>(<span>$obj</span>, <span>'myCallbackMethod'</span>));

<span>// Type 4: Static class method call (As of PHP 5.2.3)</span>
call_user_func(<span>'MyClass::myCallbackMethod'</span>);

<span>// Type 5: Relative static class method call (As of PHP 5.3.0)</span><span><span>class</span><span>A</span> {</span><span>public</span><span>static</span><span><span>function</span><span>who</span><span>()</span> {</span><span>echo</span><span>"A\n"</span>;
    }
}

<span><span>class</span><span>B</span><span>extends</span><span>A</span> {</span><span>public</span><span>static</span><span><span>function</span><span>who</span><span>()</span> {</span><span>echo</span><span>"B\n"</span>;
    }
}

call_user_func(<span>array</span>(<span>'B'</span>, <span>'parent::who'</span>)); <span>// A</span></code>

这里有5种回调类型,不仅仅是 function

学习,共勉。。

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了PHP Callback 回调类型,包括了call,back方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn