search
HomeBackend DevelopmentPHP TutorialWhat is the difference between TP5 and TP3.X

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

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

5.0 version

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

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
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
What is the difference between unset() and session_destroy()?What is the difference between unset() and session_destroy()?May 04, 2025 am 12:19 AM

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

What is sticky sessions (session affinity) in the context of load balancing?What is sticky sessions (session affinity) in the context of load balancing?May 04, 2025 am 12:16 AM

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

What are the different session save handlers available in PHP?What are the different session save handlers available in PHP?May 04, 2025 am 12:14 AM

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

What is a session in PHP, and why are they used?What is a session in PHP, and why are they used?May 04, 2025 am 12:12 AM

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

Explain the lifecycle of a PHP session.Explain the lifecycle of a PHP session.May 04, 2025 am 12:04 AM

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

What is the difference between absolute and idle session timeouts?What is the difference between absolute and idle session timeouts?May 03, 2025 am 12:21 AM

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

What steps would you take if sessions aren't working on your server?What steps would you take if sessions aren't working on your server?May 03, 2025 am 12:19 AM

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

What is the significance of the session_start() function?What is the significance of the session_start() function?May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

See all articles

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

Video Face Swap

Video Face Swap

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

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)