a) 将网页模板放在view视图中并根据名称分别创建文件夹,分模块建立
比如:首页为index.html,新闻模块有addnews.html,allnews.html,(以下内容都将采用此例)。我们可以创建这样的目录结构:
|-View | |-Index | | |-index.html | |-News | | |-add.html(addNews.html) | | |-all.html(allNews.html)
b) Controller则创建这样的目录结构
|-Controller | |-IndexController.class.php | |-NewsController.class.php
c) 目录结构有了,那我们开始敲代码了。
IndexController.class.php
display();//加载模板文件,让模板呈现在浏览器中
}
}
?>NewsController.class.php
display();
}
public function all(){
$this->display();
}
}
?>好了,这样的话,这几个页面就可以在浏览器中显示了。
d) 认识地址栏
立即学习“PHP免费学习笔记(深入)”;
1、localhost/app/ Home
模块下的Index控制器index⽅法
2、localhost/app/index.php/Home/Index/lists:
Home模块下的Index控制器lists方法
3、localhost/app/index.php/Home/News/add
Home模块下的News控制器add方法
4、localhost/app/index.php/Home/News/edit/id/2 以上就是【ThinkPHP系列篇】ThinkPHP框架使网页能够在浏览器中访问(二)的内容,更多相关内容请关注PHP中文网(www.php.cn)!











