在 Module.php 我有一些代码(简化版):
namespace Application;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
class Module{
public $somevariable = 'test';
public function onBootstrap( MvcEvent $e ) {
$this->somevariable = 'test2';
}
public function getValue(){
return $this->somevariable;
}
}
接下来,我想从模板 layout.phtml 中的变量“somevariable”中获取值。我这样做如下:
echo Application\Module::getValue();
但这不起作用。那有什么问题?
PS 我从来没有在 PHP 中进行过太多编程,所以也许我错过了一些东西 :-(