私はこれに似たコードを持っています:
$name = '_DBR'; // This comes from a function call
$this->_Inits['_DBR'] = function () { return get_library('Database')->getConnection('users', 'read'); };
$inits = $this->_Inits[$name];
$result = $inits(); // ERROR: Function name must be a string
return $result;
私が得るエラーは次のとおりです。
Function name must be a string in xxxx
配列を使用して複数のクロージャーを格納する方法はありますか?それらにアクセスする有効な方法はありますか?
私はPHP 5.4.3を使用しています