Php 注意:未定义变量:模板&;致命错误:对非对象调用成员函数writePage()

Php 注意:未定义变量:模板&;致命错误:对非对象调用成员函数writePage(),php,Php,我有个问题。当我运行我的站点时,模板会出错 我有两个错误: Notice: Undefined variable: template in /home/us22368/domains/******.nl/public_html/index.php on line 4 Fatal error: Call to a member function writePage() on a non-object in /home/us22368/domains/******.nl/public_html/i

我有个问题。当我运行我的站点时,模板会出错

我有两个错误:

Notice: Undefined variable: template in /home/us22368/domains/******.nl/public_html/index.php on line 4 
Fatal error: Call to a member function writePage() on a non-object in /home/us22368/domains/******.nl/public_html/index.php on line 4
一些代码:

index.php:

<?php
require_once('global.php');
$template->writePage('index');
$template->echoPage();
?>

My global.php包括以下类(class.template.php):



有人可以帮助我吗?

在index.php文件中,您必须创建模板类的实例:

<?php
require_once('global.php');
$template = new template();
$template->writePage('index');
$template->echoPage();
?>


查看php文档:

您必须创建一个模板实例,如
$template=new template()
您没有初始化
$template
$template=new template()
在使用任何模板类函数之前,我会遇到以下错误:
注意:未定义的属性:template::$content in/home/us22368/domains/*****.nl/public_html/app/includes/classes/class.template.php在模板类的第11行
添加一个“content”属性。
public$contentpublic$模板下的code>如@ChoiZ所说。您正在使用
$this->content
,这意味着此类应该是
content
属性
<?php
require_once('global.php');
$template = new template();
$template->writePage('index');
$template->echoPage();
?>