This article mainly introduces the method of loading views in the CI (CodeIgniter) frame view, and analyzes the related operating techniques of CodeIgniter frame view loading in the form of examples. Friends in need can refer to the following
The examples in this article describe Method of loading views in CI (CodeIgniter) framework view. 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 within views.
1: After setting the CodeIgniter database variables in the Application\config\database.php file, set the base URL in the Application\config\config.php file. For example, my basic URL is: http://localhost/codeigniter/
2: Next, create the default controller and view. The directory where the controller is created is: application\controllers\ folder. Create a A controller named student.php. and set it as default controller inside 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: http://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 entire content of this article, I hope it will be helpful to everyone Learning will be helpful. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About the method of operating redis in the CI framework
The definition and usage of public model classes of the CI framework
The above is the detailed content of About the method of loading views in CI framework view. For more information, please follow other related articles on the PHP Chinese website!