Learning ideas about ThinkPHP

迷茫
Release: 2023-03-04 20:22:01
Original
1468 people have browsed it

First let’s understand what is ThinkPHP?

ThinkPHP is a fast, compatible and simple lightweight domestic PHP development framework. It uses the mvc mode for project development. As an overall development solution, ThinkPHP can solve most needs in application development. , because it contains common components such as underlying architecture, compatibility processing, base class library, database access layer, template engine, caching mechanism, plug-in mechanism, role authentication, form processing, etc., and is suitable for cross-version, cross-platform and cross-database transplantation All are more convenient. And each component is carefully designed and perfected, and the application development process only needs to focus on your business logic.

To develop locally, we need to download the thinkphp compressed package first. We take 3.2 as an example. Download it first, and then we take a look at the directory structure, as shown in the figure below:

Learning ideas about ThinkPHP

Let’s put these files on the local server and run them. You can see this effect!

Learning ideas about ThinkPHP

So we can write programs in it!

Learning framework, I personally think the manual is very important, so I hope friends can read the manual more.

Let’s look at the following controllerController

<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $this->show();
    }
}
Copy after login

The page just displayed the image above, with a smiley face,

When we write

$this->show(“hello world”);
Copy after login

like this When, hello world

Model will be displayed on the page. Generally, our operations on the database will be written in the model, such as addition, deletion, modification, and query, and then passed to the controller. , make judgments and give prompt information.

View view, the files displayed on the front end, we will put them under the view file. We usually create several controllers when we have several database tables!

This is a standardized development method, but in our daily life, we do not develop like this. Usually we have already operated the database in the Controller and have not used the model. !

Let’s look at the following U method

{:U('address', 'parameter'...)} This may be too official language and not easy to understand. My own understanding is that it is a module /Controller/Method

For example {:U('admin/index/index')} under the admin module, look for the index method in the index controller

Use the framework for development , which will greatly save a lot of things, such as verification codes. We only need to take the code of the manual and use it in the project. The same is true for paging, but when using paging, we need to change the parameters inside.

Related labels:
source: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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template