【发布时间】:2016-05-24 17:57:24
【问题描述】:
我有这样的课程
class View
{
// Parameter die an das template übergeben werden
protected static $params = Array();
// Parameter die vom Routing übergeben werden
public static $routeParams;
// haupttemplate
protected static $viewMainContent;
// view template
protected static $viewFileContent;
// view pfad
protected static $pathTpl;
// controller pfad
protected static $pathCtrl;
protected $login;
// ausgabe des templates
public static function get($view, $params = "", $master = "main"){
$this->$login = new Login();
self::$pathTpl = Config::get('SRVROOT') . '/views/';
self::$pathCtrl = Config::get('SRVROOT') . '/controller/';
self::$routeParams = $params;
// prüfen ob main template oder custom
....................
....
另一个类是非静态类。 现在我想在我的静态类中加载非静态类。 我的 View 类我想使用我的 Login 类中的功能。
那是一个模板类,我在 View 类中有一个函数。 在这个函数中,我加载了一个定义的控制器(xxx.php),在这个文件中我想使用所有存在的类。
protected static function get_controller($file){
$ctrlFile = self::$pathCtrl . $file.'.php';
!file_exists($ctrlFile) || require_once($ctrlFile);
}
在函数包含的文件中,我有这段代码。
if($login->user()){ echo "Hallo ich bin eingeloggt"; }
浏览器报错
致命错误:未捕获的错误:在第 25 行的 /home/vagrant/Cloud/60_Projekte/SeitenVorlage/lib/class.templating.php 的对象上下文中使用 $this
我该怎么做?
【问题讨论】:
标签: php class template-engine