嗨我的問題是我的PHP模板class.the問題是當我打開index.php文件它不顯示任何東西。我不知道,但我認爲問題是與模板類
的template.php:php模板類不起作用
<?php
class Template {
protected $template;
protected $vars = array();
public function __construct($template){
$this->template = $template;
}
public function __get($key){
return $this->vars[$key];
}
public function __set($key, $value){
$this->vars[$key] = $value;
}
public function __toString(){
extract($this->vars);
chdir(dirname($this->template));
ob_start();
include basename($this->template);
return ob_get_clean();
}
}
?>
頭版:
<?php include('includes/header.php'); ?>
test
<?php include('includes/footer.php'); ?>
的index.php:
<?php
require 'ini.php';
$template = new Template('templates/frontpage.php');
echo $template;
?>
ini.php:
<?php
session_start();
function __autoload ($class_name){
require_once('libraries/'.$class_name'.php');
}
?>
注意:在frontpage.php正常工作。
您的網頁上是否有任何錯誤可見?如果沒有,請確保報告錯誤:'error_reporting(E_ALL);'。 – Jer