CI(CodeIgniter)框架视图中加载视图的方法
网络编程 2021-07-05 08:23www.168986.cn编程入门
这篇文章主要介绍了CI(CodeIgniter)框架视图中加载视图的方法,结合实例形式分析了CodeIgniter框架视图加载相关操作技巧,需要的朋友可以参考下
本文实例讲述了CI(CodeIgniter)框架视图中加载视图的方法。分享给大家供大家参考,具体如下:
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 内将其设置为默认控制器。
Controller->student.php
class Student extends CI_controller{ public function __construct(){ parent::__construct(); } public function index(){ $date['title']="Classroom:Home Page"; $date['headline']="Wele 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://.w3./TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://.w3./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 plate!
如果你访问:http://localhost/CodeIgniter/index.php/student/index
the result will output:
Wele to the Classroom Management System Congratulations.Your initial setup is plate!
更多关于CodeIgniter相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家基于CodeIgniter框架的PHP程序设计有所帮助。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程