


[ThinkPHP Series] The ThinkPHP framework enables web pages to be accessed in the browser (2)
a) Place the web page template in the View view and create folders according to the names, and create them in modules
For example: the homepage is index.html, the news module has addNews.html, allNews.html, (the following contents are This example will be used). We can create such a directory structure:
|-View | |-Index | | |-index.html | |-News | | |-add.html(addNews.html) | | |-all.html(allNews.html)
b) The Controller creates such a directory structure
|-Controller | |-IndexController.class.php | |-NewsController.class.php
c) Now that the directory structure is in place, we start typing the code.
IndexController.class.php <?php namespace Home\Controller;//命名空间 use Think\Controller;//使用Think目录中的核心函数 class IndexController extends Controller{ public function index(){ $this->display();//加载模板文件,让模板呈现在浏览器中 } } ?>
NewsController.class.php <?php namespace Home\Controller; use Think\Controller; class NewsController extends Controller{ public function add(){ $this->display(); } public function all(){ $this->display(); } } ?>
Okay, in this case, these pages can be displayed in the browser.
d) Understanding the address bar
1、localhost/app/ Home 模块下的Index控制器index⽅法 2、localhost/app/index.php/Home/Index/lists: Home模块下的Index控制器lists方法 3、localhost/app/index.php/Home/News/add Home模块下的News控制器add方法 4、localhost/app/index.php/Home/News/edit/id/2
The above is the [ThinkPHP series] ThinkPHP framework enables web pages to be accessed in the browser (2). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
