thinkphp, how to distinguish a common function, when should be written in common.php, when should be written in the parent class (Public inheritance Class) inside?

Source: Internet
Author: User
Title, I am a little confused, such as a function of intercepting string length, should I write in common.php or in the parent class (Public inheritance Class)?
Also, what is the difference between these two implementations for performance?
Please talk about your own experience.

Reply content:

Title, I am a little confused, such as a function of intercepting string length, should I write in common.php or in the parent class (Public inheritance Class)?
Also, what is the difference between these two implementations for performance?
Please talk about your own experience.

Most of the places are written in common.php Ah, you write in config.php can also, just thinkphp the conventional, if only a single action to write in action

Basic functions Drop common.php directly.
For example, we will enclose the text message in a new class.

In terms of performance, this is not worth considering. Focus on business logic.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.