CodeIgniter is a small but powerful PHP framework. You can download the framework from the official website. The following describes the simple operations in CodeIgniter. 1. Create and set the Controller. 1. Create the blog. php file in the Controller Directory: 2. The code in blog. php is as follows :? PhpclassBlogextendsCI_C
CodeIgniter is a small but powerful PHP framework. You can download the framework from the official website. The following describes the simple operations in CodeIgniter. 1. Create and set the Controller. 1. Create the blog. php file in the Controller Directory: 2. The code in blog. php is as follows :? Phpclass Blog extends CI_C
CodeIgniter is a small but powerful PHP framework.
You can download the framework from the official website.
The following describes the simple operations in CodeIgniter.
1. Create and Set Controller
1. Create the blog. php file in the Controller directory:
2. The code in blog. php is as follows:
3. Enter the address. Note: Do not add a suffix. Browsing page:
The data shown here is actually the data in the index function, because the index method is called by default.
Modify the Code as follows:
After modifying the access path, you will find that the input or no input/index is the access index method. However, if you enter other values, you will access the content of other functions:
In CodeIgniter, many settings have been configured, And we can modify them directly.
For example, to modify the default access page, there is a route. php In applications/config:
$route['default_controller'] = "welcome";$route['404_override'] = '';
Change default_controller to blog, and enter index. php In the taskbar. The output is HelloWorld, that is, the blog. php page is accessed:
Ii. Create and set a View
1. Create a file blog_view.php in the views directory:
2. Return to blog. php In the controller folder and load the blog_view page with simple echo to realize the true value of its controller:
load->view('blog_view');}}?>
3. Enter the URL on the page to access the website. The page has changed:
3. data transmission between Controller and View
1. modify the code in Controller as follows:
load->view('blog_view',$data);}}?>
2. modify the code in the View as follows. Note that instead of using the data array, you can call data directly:
<?php echo $myName.$head?>I am
3. browse the website:
PS: In CodeIgniter Equivalent
Use php to output an array.
1. Add an array with the following changes in the Controller:
load->view('blog_view',$data);}}?>
2. Modify the display array in View as follows:
<?php echo $myName.$head?>I am
-
3. Refresh the page and the page will be displayed normally:
If you are not used to endforeach, you can also use the standard PHP language:
<?php echo $myName.$head?>I am
-
Of course, you can also rewrite the constructor method:
load->view('blog_view',$data);}}?>