国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

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

2024-05-04 23:56:15
字體:
來源:轉載
供稿:網友

本文實例講述了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

<!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 SystemCongratulations.Your initial setup is complate!

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


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 澄江县| 崇阳县| 乌鲁木齐县| 高安市| 鲁山县| 中西区| 新宾| 个旧市| 石台县| 五大连池市| 泾阳县| 延吉市| 准格尔旗| 吴堡县| 龙陵县| 酒泉市| 连云港市| 常山县| 林周县| 青铜峡市| 彩票| 东兴市| 习水县| 德惠市| 长治市| 同江市| 偏关县| 扶风县| 济阳县| 洛浦县| 安多县| 云安县| 杭州市| 黄陵县| 郎溪县| 类乌齐县| 平泉县| 江华| 永胜县| 甘肃省| 西和县|