CI 视图中加载视图
2015-11-30 19:55
344 查看
CI做为php的一个轻量级框架,其自身具备很多优点,在此我重点想说的是视图中加载视图。
1:在Application\config\database.php文件中设置好CodeIgniter 数据库变量之后,紧接着在Application\config\config.php文件中设置基础 URL。例如我的基础 URL 是:http://localhost/codeigniter/
2:接下来创建默认的控制器与视图,创建控制器的目录为:application\controllers\ 文件夹内,创建一个名为 student.php 的控制器。并在 application\config\routes.php 内将其设置为默认控制器。
如果你访问:http://localhost/CodeIgniter/index.php/student/index
the result wiil output:
参考资料:https://www.ibm.com/developerworks/cn/opensource/os-codeigniter/
1:在Application\config\database.php文件中设置好CodeIgniter 数据库变量之后,紧接着在Application\config\config.php文件中设置基础 URL。例如我的基础 URL 是:http://localhost/codeigniter/
2:接下来创建默认的控制器与视图,创建控制器的目录为:application\controllers\ 文件夹内,创建一个名为 student.php 的控制器。并在 application\config\routes.php 内将其设置为默认控制器。
Controller->student.php
class Student extends CI_controller{ public function __construct(){ parent::__construct(); } public function index(){ $date['title']="Classroom:Home Page"; $date['headline']="Welcome to the Classroom Management System"; $date['include']="Student_index"; $this->load->view('template',$date); } }
views->template.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title><?php echo $title;?></title> </head> <body> <h1><?php echo $headline;?></h1> <?php $this->load->view($include);?> </body> </html>
view->student_index.php
Congratulations.Your initial setup is complate!
如果你访问:http://localhost/CodeIgniter/index.php/student/index
the result wiil output:
Welcome to the Classroom Management System
Congratulations.Your initial setup is complate!
参考资料:https://www.ibm.com/developerworks/cn/opensource/os-codeigniter/
相关文章推荐
- Android Button的3D触摸效果
- 解决在IE中获取数据的缓存问题,运行环境为node.js
- sphinx里 java接口中对错误信息封装的一点记录
- Android 解决BitmapFactory.decodeFile(file) 报OOM问题
- NSString、NSMutableString基本用法
- MyEclips启动报错:'Building workspace' has encountered a problem的解决方法
- C++11学习笔记7---资源回收RAII
- UI基础-UI高级 可视化设计
- 敏捷开发 scrum管理
- 【数据结构】栈结构操作示例
- DNS劫持
- OC-1-面向对象
- <18> go time
- 网络层—网络层提供的两种服务
- awk之RS、ORS、FS、OFS基础及举例
- 第八周实践项目4—字符串加密
- HPU 1716: 感恩节KK专场——考试来了【水】
- 重振雄风---2015年11月英语月总
- 个人博客+移动端开发(前言)
- OC-7-内存管理