__callStatic 學習

介紹:當類調用靜態方法是,並且調用的方法不存在時,會調用 __callStatic 方法

類代碼:

class Test
{
    public static function __callStatic($name, $arguments)
    {
        dump($name);
        dump($arguments);
    }
}

 調用代碼: 

\Test::abc("1", "2", "3");

 

 執行結果:

string(3) "abc"
array(3) {
  [0] => string(1) "1"
  [1] => string(1) "2"
  [2] => string(1) "3"
}

 

 

 

 

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