Home Backend Development PHP Tutorial What is the difference between TP5 and TP3.X

What is the difference between TP5 and TP3.X

Aug 09, 2017 am 10:15 AM
thinkphp

The differences between TP5 and TP3. 3. The database query function of TP5 has been enhanced, and the original M function call can be replaced by the db function.

What is the difference between TP5 and TP3.X

Since TP5.0 is a brand new subversive and reconstructed version, many interviewers now like to ask about the difference between TP3.2 and TP5. Then What are the differences between them?

1. Directory

What is the difference between TP5 and TP3.X

What is the difference between TP5 and TP3.X

##TP5 Directory

What is the difference between TP5 and TP3.X

2. 3.X old ideas that need to be abandoned

URL Changes

First of all, I would like to apologize for the incorrect guidance that the laxity of 3. get' method to obtain 'id'. Strictly speaking, such URL does not belong to $_GET. It can now be obtained through 'param'. The specific use can be queried through the request part.

Model changes

The new version of the model query returns the default 'object', and the system adds the 'toArray' method by default. Many developers are 'all' or 'select' try to use 'toArray' to convert to an array. We hope developers can understand the concept of 'object', try to use 'object' for data use, or use the 'db' method for database operations. , and also remind some developers who abuse 'toArray', the result of 'all' or 'select' is an array collection of objects, which cannot be converted using 'toArray'.

3. Controller version comparison

tp3

What is the difference between TP5 and TP3.X

tp5

What is the difference between TP5 and TP3.X

TP3.2 controller name must end with Controller.class.php, while TP5 ends with .php;

TP3.2 controller template output uses $ this->display() method. In TP5, if the basic controller is inherited, use the $this->fetch() method. If it is not inherited, just use the view() assistant function;

Model

The database query function of 5.0 has been enhanced. The chain query that originally needed to be used through the model can be called directly through the Db class. The original M function call can be changed to the db function, for example:

3.2 version

1

M('User')->where(['name'=>'thinkphp'])->find();

Copy after login

5.0 version

1

db('User')->where('name','thinkphp')->find();

Copy after login

4. Assistant function

5.0Assistant function and3.2 The version of the single-letter function comparison is as follows:

For more related knowledge, please visit

PHP Chinese website! !

The above is the detailed content of What is the difference between TP5 and TP3.X. For more information, please follow other related articles on the PHP Chinese website!

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 Article Tags

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)

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

How to install thinkphp

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Which one is better, laravel or thinkphp?

Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Nov 22, 2023 pm 12:01 PM

Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks

ThinkPHP6 data encryption and decryption: protecting sensitive data security ThinkPHP6 data encryption and decryption: protecting sensitive data security Aug 25, 2023 pm 10:52 PM

ThinkPHP6 data encryption and decryption: protecting sensitive data security

How is the performance of thinkphp? How is the performance of thinkphp? Apr 09, 2024 pm 05:24 PM

How is the performance of thinkphp?

See all articles