Heim  >  Artikel  >  Backend-Entwicklung  >  关于函数 call 的一个疑问

关于函数 call 的一个疑问

WBOY
WBOYOriginal
2016-06-23 13:49:59931Durchsuche

这个函数是不是就像c++中的的多态啊。


回复讨论(解决方案)

我不知道这个问题是不是很白痴。。

PHP5 的对象新增了一个专用方法 __call(),这个方法用来监视一个对象中的其它方法。如果你试着调用一个对象中不存在或被权限控制中的方法,__call 方法将会被自动调用。

class p{	function __call($name,$arg){		echo "you have this method $name?";	}}$o = new p();$o->pp();


you have this method pp?

PHP5 的对象新增了一个专用方法 __call(),这个方法用来监视一个对象中的其它方法。如果你试着调用一个对象中不存在或被权限控制中的方法,__call 方法将会被自动调用。

class p{	function __call($name,$arg){		echo "you have this method $name?";	}}$o = new p();$o->pp();


you have this method pp?




我知道怎么用。就是突然这么想了。
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn