重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
這篇文章將為大家詳細講解有關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
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框架視圖中如何加載視圖”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。