当前位置: 首页 > 图文教程 > 网络编程 > PHP > 利用PHP实现一种轻量级的MVC结构(原创)

PHP
如何批量修改RAR文件注释
XAMPP环境下mysql的root用户密码修改方法
PHP教程:最全的CURL函数库中文说明
十三个WordPress SQL查询语句
PHP技巧汇总:提高PHP性能的53个技巧
用JQuery和PHP实现无刷新删除数据库数据
PHP教程:smarty学习指南
CentOS+Nginx+PHP+MySQL环境配置
PHP 5.2.13版发布修复之前30多个BUG
PHP实例教程:PHP采集程序的思路
Apache 2.2.15版发布
PHP实例教程:汉字转为unicode的通用函数
Windows7系统安装Apache_pn服务失败
PHP实例教程:PHP开启gzip页面压缩
PHP教程:strtok()函数实际应用
FireFox插件FirePHP调试PHP
PHP 正则判断中文 UTF-8 & GBK
PHP中处理string

利用PHP实现一种轻量级的MVC结构(原创)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 52 ::
收藏到网摘: n/a

本文转自:http://hsboy.com/blog/archives/158-uPHPOEOEOECaAEMVCa.html

  PHP的优点就在于轻量和跨平台。它和Apache以及Mysql的联合可以提供一种十分廉价的解决方案,这在开发和部署上都能体现出来。本人之所以执着于PHP也是因为这一点(虽然本人对于PHP的怨言也有不少,暂且不表)。

    MVC结构是不是好的结构,它有哪些优点,是否适合于WEB或者是否适合于使用PHP进行开发的WEB项目,这在很多文章中都提到过。这里÷粤恕J导噬希???HP以及一些现成的开远项目,确实可以做出很清晰简洁的架构,这也是本文的目标所在。

一、Model部分

    Model中包含bean以及bean的有效性检验代码,下面是Bean类的实现:

<?php
class
Bean
{
    protected
$_bean_name = NULL
;
    private
$_bean_array = NULL
;

    
/**
     * set the name of the bean
     *
     * @param $name string the bean name to set
     * @return void
     */
    
public function set_name($name
)
    {
        
$this->_bean_name = $name
;
    }

    
/**
     * get the name of the bean
     *
     * @return string the name of the current bean
     */
    
public function get_name
()
    {
        return
$this->_bean_name
;
    }

    
/** constructor, build a bean from a array and the name of the bean */
    
public function __construct($bean_name, &$bean_array
)
    {
        
$this->set_name($bean_name