PHP7下web類應用報錯 Methods with the same name as

Methods with the same name as their class will not be constructors in a future version of PHP ...

這個報錯的原因是 PHP7 不再支持與類名相同的構造方法,構造方法統一使用 __construct(), 比如下面的寫法 PHP7 就會報這個錯誤。

<?php  
class foo {  
    function foo() {
        echo 'I am the constructor';
    }
}
?>

將構造方法 ECS 修改爲 __construct,
刷新首頁,發現已經沒有錯誤了


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章