时间:2021-07-01 10:21:17 帮助过:19人阅读
--------------------文件夹结构-------------------------
主文件夹mvc_demo
--controllers
--ArticleController.php
--UserController.php
--models
--UserModel.php
--views
--User/index.php
index.php //入口文件
-----------------------------------------------------------
index.php
$a();
UserController{
		
		public function index(){
			//echo "这是User控制器的index方法";
			//包含文件并实例化一个模型
			include './models/UserModel.php';
			
			//通过模型获取数据
			$model = new UserModel();
			$str=$model->getUser();
			
			include './views/User/index.php';
		}
	}
views/User/index.php
在浏览器中输入http://localhost:8080/mvc_demo/index.php?c=User&a=index,显示效果使用者helen。
以上就介绍了一个简易的MVC模型,包括了UserControl方面的内容,希望对PHP教程有兴趣的朋友有所帮助。