<?php
class Cat {
}
class Hypnotic_Cat extends Cat {
// Constructor
function Hypnotic_Cat( ) {
}
// This function must be called statically
public static function hypnotize( ) {
echo ("The cat was hypnotized.");
//return;
}
}
// Hypnotize all cats
//Hypnotic_Cat::hypnotize( );
$hypnotic_cat = new Hypnotic_Cat( );
// Does nothing
$hypnotic_cat->hypnotize( );
?>
为什么用->后可以有结果显示?静态方法不是只能用::来调用吗?
尚方宝剑之说