0
class Controller {
protected $_controller;
protected $_action;
protected $_template;
public $doNotRenderHeader;
public $render;
function __construct($controller, $action) {
$this->_controller = ucfirst($controller);
$this->_action = $action;
$model = ucfirst($controller);/* Conecting the model class*/
$this->doNotRenderHeader = 0;
$this->render = 1;
$modelName = ucfirst($model).'Model';
new $modelName;
$this->_template = new Template($controller,$action);
}
function set($name,$value) {
$this->_template->set($name,$value);
}
function __destruct() {
if ($this->render) {
$this->_template->render($this->doNotRenderHeader);
}
}
}
我在使用类一个新手,我不明白这么多,我想实现,并研究与类MVC结构的这个例子的工作,但我有一个问题,与我保存到阵列的功能集,一些信息,然后以类模板内发送,当我使用内部函数__construct我与集发送()函数,必须将数据存入$ this_template对象的角色,它的好的工作,但是当我创建这个类或扩展类的新功能,是不工作...帮助与PHP类
的问题是 - 怎么做,当我创建Controller类的功能,以摆阵我需要的价值,与他们一起在t班内工作emplate :) 非常感谢帮助..和对不起我从类控制器英语
class Template {
protected $variables = array();
function set($name,$value) {
$this->variables[$name] = $value;
}
function render(){
extract($this->variables); print_r($this->variables);
}
}
我需要的功能集()导出数据类模板里面,为什么当我创建类控制器内部的功能 例如:
function functionName() {
$data=array('a','b');
$this->set('data',$data);
}
和内部class Template
,我把print_r($this->variables);
,且数组为空
北京时间什么你的问题?我不明白。 – 2009-10-31 19:20:33
看看az Zend框架,了解PHP中的MVC – erenon 2009-10-31 19:22:33
我没有那么多时间,我在一个项目上工作..而在这个时候,我正在学习mvc结构,并与类一起工作 – mIRU 2009-10-31 19:30:00