0

这是我的代码

/**
 * 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(),假设 $this 来自第 49 行 /home/zxcvbnm/public_html/app/cache/_home_zxcvbnm_public_html_app_views_invoice_admininvoice.volt.php 中的不兼容上下文

如何动态调用方法?

4

1 回答 1

1

If you want to call your method is statically, you must change the method implementation to static:

public static function paymentStatus($key){
     ...code
}
于 2015-09-18T14:26:38.810 回答