全民工作狂
2015-09-29 23:47
<?php
class testController{
function show(){ //控制器的作用时调用模型,并调用视图,将模型产生的数据传递给视图,并让相关视图去显示
$testModel = new testModel();
$data = $testModel->get();
$testView = new testView();
$testView->$display($data);
}
}
?><?php
class testModel{
function get(){ //模型的作用时获取数据并处理返回数据
return "Hello World!";
}
}
?>testView.class.php
<?php
class testView{
function display($data){ //视图的作用时将取得的数据进行组织,美化等,并最终向用户终端输出
echo $data;
}
}
?><?php
//如果有错,include()报一个警告
//如果有错,require_once()报一个严重错误
require_once('testController.class.php');
require_once('testModel.class.php');
require_once('testView.class.php');
$testController = new testController();
$testController->show();
?>
testController里的这个地方 $testView->$display($data); 写错了,应该是$testView->display($data);
MVC架构模式分析与设计
82450 学习 · 954 问题
相似问题