可能重複:
Is there a way to program 100% object-oriented in PHP?在Java中,是否有`public static main(String [] args)`的PHP等價物?
我所試圖實現將是這個樣子:
<?php
//index.php
class Site{
public static function main(){
// starts all the processing of the site
}
}
?>
所以,當有人訪問該網站的index.php
網站將在課堂外沒有任何代碼的情況下啓動。
是的我知道我可以使用__autoload
甚至spl_autoload_register
來處理類的自動加載,但仍然很可能需要添加到類之外。
我懷疑這是可能的,但我不知道爲什麼這是不可能的。
爲什麼你需要一個入口點在PHP? – perilbrain
@deceze是的,它看起來可能會滿足我的問題的要求,但是我經常搜索它的結果從未出現過。可能是因爲我在搜索中使用了錯誤的信息。 – JRSofty
是的,有... 公共職能__construct(){/ *做對象建設* /} – Matth3w