這兩段代碼有什麼區別?php靜態方法問題
class something {
static function doit() {
echo 'hello world';
}
}
something::doit();
和相同的,但沒有static關鍵字
class something {
function doit() {
echo 'hello world';
}
}
something::doit();
他們都工作,同樣是它更好地使用靜態關鍵字?我的理解是,如果使用靜態方法,它不會實例化類?
它適用於PHP4及以下版本。 – Arvin 2011-02-03 10:00:39