Heim >Backend-Entwicklung >PHP-Tutorial > php的静态方法调用有关问题,求大牛解答
php的静态方法调用问题,求大牛解答
<br /> <br /> <?php<br /> class Cat {<br /> }<br /> class Hypnotic_Cat extends Cat {<br /> // Constructor<br /> function Hypnotic_Cat( ) {<br /> }<br /> // This function must be called statically<br /> public static function hypnotize( ) {<br /> echo ("The cat was hypnotized.");<br /> //return;<br /> }<br /> }<br /> // Hypnotize all cats<br /> //Hypnotic_Cat::hypnotize( );<br /> $hypnotic_cat = new Hypnotic_Cat( );<br /> // Does nothing<br /> $hypnotic_cat->hypnotize( );<br /> ?><br />