


[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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
