标签:
1 testModel.class.php(模型)
2 <?php
3 class testModel{
4 function getData(){
5 return ‘hello world‘;
6 }
7 }
8 ?>
9
10 testView.class.php(视图)
11 <?php
12 class testView{
13 function display($data){
14 echo $data;
15 }
16 }
17 ?>
18
19 testController.class.php(控制器)
20 <?php
21 class testController{
22 function show(){
23 $testModel = new testModel();
24 $data = $testModel->getData();
25 $testView = new testView();
26 $testView->display($data);
27 }
28 }
29 ?>
30
31 协同工作
32 testMVC.php
33 <?php
34 require_once(‘testController.class.php‘);
35 require_once(‘testModel.class.php‘);
36 require_once(‘testView.class.php‘);
37 $controller = new testController();
38 $controller->show();
39 ?>
标签:
原文地址:http://www.cnblogs.com/jiavan/p/4188617.html