ci mysql 加载_CI(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']="Welcome to the Classroom Management System";

$date['include']="Student_index";

$this->load->view('template',$date);

}

}

views->template.php

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<?php echo $title;?>

<?php echo $headline;?>

<?php $this->load->view($include);?>

view->student_index.php

Congratulations.Your initial setup is complate!

如果你访问:http://localhost/CodeIgniter/index.php/student/index

the result will output:

Welcome to the Classroom Management System

Congratulations.Your initial setup is complate!

希望本文所述对大家基于CodeIgniter框架的PHP程序设计有所帮助。

这就是微学网-程序员之家为你提供的"CI(CodeIgniter)框架视图中加载视图的方法"希望对你有所帮助.本文来自网络,转载请注明出处:http://www.weixuecn.cn/article/6892.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值