The difference between tp3.2 and tp5.0

1. Deprecation of single-letter functions, use helper functions

 The comparison between the 5.0 helper function and the single-letter function of version 3.2 is as follows:

Get and set configuration parameters throw exception handling Debug time and memory usage Get language variable value Get input data supports default values ​​and filtering Instantiate the Model Instantiate the database class Instantiate the controller     Url generation cache management
version 3.2 C E G L I D M A U S
version 5.0 config exception debug lang input model db controller url cache

2. The method of controller template output

3.2

$this->display()

5.0

return view('index/hello');

or

return $this->fetch('index/hello');

3. Controller naming

The namespace of the application class library is unified as app (can be modified)

The class name of the controller does not have the Controller suffix by default, and the controller_suffix parameter can be configured to enable the controller class suffix

3.2

IndexController.class.php

5.0

Index.php

4. Model

Naming, model class suffix without Model

D('User')->where(['name'=>'thinkphp'])->find();
model('User')->where('name','thinkphp')->find();

 5. Database operation writing method

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

5. Obsolete system constants

System constants deprecated in 5.0

REQUEST_METHOD、IS_GET、IS_POST、IS_PUT、IS_DELETE、IS_AJAX、__EXT__、COMMON_MODULE、MODULE_NAME、CONTROLLER_NAME、ACTION_NAME、APP_NAMESPACE、APP_DEBUG、MODULE_PATH等

6. getField method

Use the value and column methods in 5.0

value gets the value of a field in a record;

column gets the value of a column;

7. Request object and response object

In 5.0, the request object Request and the response object Response are newly added. Request processes requests and obtains request information in a unified manner, and the Response object is responsible for outputting client or browser responses.

Guess you like

Origin blog.csdn.net/qq_36611673/article/details/125542638