資源簡介
標(biāo)題上我把這個留言板叫最簡單的,其實應(yīng)該叫最簡陋的,因為把全部注意力集中在MVC模式設(shè)計和實現(xiàn)上,所以UI方面幾乎沒有一點修飾。之所以在這里跟大家分享這個東西,是因為我自己通過讀該老外的代碼并仿照著寫留言板對MVC的概念和具體實現(xiàn)有了些認識,希望了解MVC具體實現(xiàn)的朋友可以參考一下。
代碼片段和文件信息
ta?http-equiv=“Content-Type“?content=“text/html;?charset=gb2312“?/>
tle>PHP?MVC留言板 tle>
添加新留言
//!index.php?總?cè)肟?br/>?/**
?*?index.php的調(diào)用形式為:
?*?顯示所有留言:index.php?action=list
?*?添加留言????:index.php?action=post
?*?刪除留言????:index.php?action=delete&id=x
?*/
require_once(‘lib/DataAccess.php‘);
require_once(‘lib/Model.php‘);
require_once(‘lib/View.php‘);
require_once(‘lib/Controller.php‘);
//創(chuàng)建DataAccess對象(請根據(jù)你的需要修改參數(shù)值)
$dao=&?new?DataAccess?(‘localhost‘‘root‘‘‘‘test‘);
//根據(jù)$_GET[“action“]取值的不同調(diào)用不同的控制器子類
$action=$_GET[“action“];
switch?($action)
{
???case?“post“:
??????$controller=&?new?postController($dao$_POST);?break;
???case?“l(fā)ist“:
??????$controller=&?new?listController($dao);?break;
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1159??2009-02-25?10:57??finenote\index.php
?????文件???????1673??2009-02-25?10:17??finenote\lib\Controller.php
?????文件???????1473??2009-02-25?09:40??finenote\lib\DataAccess.php
?????文件???????1441??2009-02-25?10:58??finenote\lib\Model.php
?????文件???????1599??2009-02-25?10:38??finenote\lib\View.php
?????文件????????663??2009-02-25?10:41??finenote\post.htm
?????文件????????919??2009-02-25?11:52??finenote\sql\SQL.txt
?????文件?????????91??2009-03-11?18:57??finenote\說明.txt
?????目錄??????????0??2009-03-11?17:25??finenote\lib
?????目錄??????????0??2009-03-11?17:25??finenote\sql
?????目錄??????????0??2009-03-11?17:25??finenote
-----------?---------??----------?-----??----
?????????????????9018????????????????????11
評論
共有 條評論