同一个父类,两个子类方法互相调用有关问题

WBOY
Release: 2016-06-13 12:26:41
Original
979 people have browsed it

同一个父类,两个子类方法互相调用问题?

<br /><br />include 'model.php';<br />include 'user.php';<br /><br />class caiji extends model{<br /><br /> public function hi($name){<br />   <br />   echo "$name to you say hi \n";<br />   user::say('jack'); //这里调用非静态的类。<br />   user::hello('kate');//这里可以调用静态的没错<br /> }<br /><br />/***************两个类是分开两个文件,用include包含进来的<br /><br />class user extends model{<br /><br /> public static function hello($name){<br />   <br />     echo "$name url ".self::$weburl."\n";	<br /><br />  }<br />	<br />  public function say($name){<br />	echo "$name say hello world~~ \n";<br />  }<br /><br /><br /><br />想请问下:同一个父类,子类之间互相调用对方的方法,非静态类如果使用 类名::方法名  会提示Strict Standards: Non-static method caiji::hi() should not be called statically  这种错误。<br /><br />是不是需要调用先实例化类后 ,才能调用user 类的方法?<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
Copy after login

------解决思路----------------------
是的,非静态方法要先实例化后再调用

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template