Home  >  Article  >  PHP Framework  >  A brief analysis of the differences and usage scenarios between I() and create() methods in ThinkPHP

A brief analysis of the differences and usage scenarios between I() and create() methods in ThinkPHP

藏色散人
藏色散人forward
2021-12-27 16:06:292370browse

The following thinkphp framework tutorial column will give you a brief analysis of the differences and usage scenarios of the I() and create() methods in ThinkPHP. I hope it will be helpful to friends in need!

A brief analysis of the differences and usage scenarios between I() and create() methods in ThinkPHP

What is the difference between the I() method receiving data and the create() method receiving data in ThinkPHP?

Difference:

  • The I() method will automatically filter html entities;

  • ## The #create method needs to manually call the filter method of the model after automatic creation. Create includes automatic creation of data objects, automatic verification, automatic completion, and field mapping.

Which one is generally used more frequently?

  • When the number of accepted fields is small and those automatic functions are not needed, use the

    I() function;

  • Accepts a large number of fields, uses the

    create() method, and can complete many functions when creating data, which is convenient and fast.

Recommended study: "

The latest 10 thinkphp video tutorials"

The above is the detailed content of A brief analysis of the differences and usage scenarios between I() and create() methods in ThinkPHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete