这是我的代码
/**
* Setting up the view component
*/
$di->setShared('view', function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_'
));
$volt->getCompiler()->addFunction(
'paymentStatus',
function($key)
{
return @"Info::paymentStatus({$key})";
}
);
return $volt;
},
'.phtml' => 'Phalcon\Mvc\View\Engine\Php'
));
return $view;
});
错误信息(诚实地说)
严格标准:非静态方法Info :: paymentStatus()不应静态调用,假设$ 49来自第49行/home/zxcvbnm/public_html/app/cache/_home_zxcvbnm_public_html_app_views_invoice_admininvoice.volt.php中不兼容的上下文
如何动态调用方法?
答案 0 :(得分:1)
如果要静态调用方法,则必须将方法实现更改为static:
public static function paymentStatus($key){
...code
}