0
这里里面是类:PHP访问同一个类中包含的类
的functions.php
class buildPage {
public function Set($var,$val){
$this->set->$var = $val;
}
function Body(){
ob_start();
include('pages/'.$this->set->pageFile);
$page = ob_get_contents();
ob_end_clean();
return $page;
}
function Out(){
echo $this->Body();
}
}
因此,这里是脚本的主要(索引页)。
的index.php
include_once('include/functions.php');
$page = new buildPage();
$page->Set('pageTitle','Old Title');
$page->Set('pageFile','about.php');
$page->Out();
现在你可以看到,它包括about.php通过类文件,其实里面的类。
现在,我想访问相同的buildPage()类来更改页面标题。
about.php
<?php
$this->Set('pageTitle','New Title');
echo '<h1>About Us</h1>';
?>
但遗憾的是,没有任何反应。
请善待,花几分钟时间给我一些帮助!
我想你确实应该这样说的:HTTP: //codeangel.org/articles/simple-php-template-engine.html – 2012-04-01 14:56:50
感谢您的评论! – pnm123 2012-04-01 15:02:53