Home > Article > Backend Development > Detailed explanation of the method of loading views in CI framework view
This article mainly introduces CI (CodeIgniter)frameworkViewThe method of loading views in the CodeIgniter framework view is analyzed in the form of examples. Friends in need can refer to the following
The example of this article describes the loading of views in the CI (CodeIgniter) framework view. Method. Share it with everyone for your reference. The details are as follows:
As a lightweight framework of PHP, CI has many advantages. What I want to focus on here is loading views in views.
1: After setting the CodeIgniter database variable in the Application\config\database.php file, set the base URL in the Application\config\config.php file. For example, my base URL is: localhost/codeigniter. /
2: Next, create the default controller and view. The directory where the controller is created is: application\controllers\ folder. Create a controller named student.php . and set it as the default controller in 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!
If you visit: localhost/CodeIgniter/index.php/student/index
the result will output:
Welcome to the Classroom Management System Congratulations.Your initial setup is complate!
The above is the detailed content of Detailed explanation of the method of loading views in CI framework view. For more information, please follow other related articles on the PHP Chinese website!