foldrr's weblog

旧ブログ http://d.hatena.ne.jp/foldrr/

PHP call_user_method(_array) で Notice が発生する

環境

問題

call_user_method を使おうとすると下記 Notice が発生する。

PHP Notice:  call_user_method_array(): This function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in ...

原因

call_user_method_array() は非推奨の関数であるため。

解決方法

call_user_func(_array) をつかう>
call_user_func_array は第1引数で指定した名前の関数を呼び出すが、第1引数に array(オブジェクト, "メソッド名") を渡すと、メソッドも呼べる。