亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

CI(CodeIgniter)框架視圖中加載視圖的方法

 更新時(shí)間:2017年03月24日 10:56:18   作者:PHP__廊外詩鴿  
這篇文章主要介紹了CI(CodeIgniter)框架視圖中加載視圖的方法,結(jié)合實(shí)例形式分析了CodeIgniter框架視圖加載相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了CI(CodeIgniter)框架視圖中加載視圖的方法。分享給大家供大家參考,具體如下:

CI做為php的一個(gè)輕量級框架,其自身具備很多優(yōu)點(diǎn),在此我重點(diǎn)想說的是視圖中加載視圖。

1:在Application\config\database.php文件中設(shè)置好CodeIgniter 數(shù)據(jù)庫變量之后,緊接著在Application\config\config.php文件中設(shè)置基礎(chǔ) URL。例如我的基礎(chǔ) URL 是:http://localhost/codeigniter/

2:接下來創(chuàng)建默認(rèn)的控制器與視圖,創(chuàng)建控制器的目錄為:application\controllers\ 文件夾內(nèi),創(chuàng)建一個(gè)名為 student.php 的控制器。并在 application\config\routes.php 內(nèi)將其設(shè)置為默認(rèn)控制器。

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 will output:

Welcome to the Classroom Management System
Congratulations.Your initial setup is complate!

更多關(guān)于CodeIgniter相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《ThinkPHP入門教程》、《ThinkPHP常用方法總結(jié)》、《Zend FrameWork框架入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家基于CodeIgniter框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論