Home php教程 PHP开发 [ThinkPHP Series] The ThinkPHP framework enables web pages to be accessed in the browser (2)

[ThinkPHP Series] The ThinkPHP framework enables web pages to be accessed in the browser (2)

Dec 28, 2016 am 10:37 AM
thinkphp framework

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)
Copy after login

b) The Controller creates such a directory structure

|-Controller
| |-IndexController.class.php
| |-NewsController.class.php
Copy after login

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();//加载模板文件,让模板呈现在浏览器中
    }
}
?>
Copy after login
NewsController.class.php
<?php
namespace Home\Controller;
use Think\Controller;
class NewsController extends Controller{
    public function add(){
        $this->display();
    }
    public function all(){
        $this->display();
    }
}
?>
Copy after login

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
Copy after login

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)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)