Is it good to put the copy in the code or in the config file?

Source: Internet
Author: User
Keywords Php
The project has a wide variety of copywriting, often appearing if what, what the case is. Write the hint text directly in the function code, 1. Difficult to see, 2. To modify the time to find trouble, but if placed in the configuration file, the configuration file to put a variety of copy, the file will be very large, when the need for these files, loading the contents of the configuration file also seems to waste overhead. I don't know which way is better, or there is no better solution.

Reply content:

The project has a wide variety of copywriting, often appearing if what, what the case is. Write the hint text directly in the function code, 1. Difficult to see, 2. To modify the time to find trouble, but if placed in the configuration file, the configuration file to put a variety of copy, the file will be very large, when the need for these files, loading the contents of the configuration file also seems to waste overhead. I don't know which way is better, or there is no better solution.

The copy you're talking about is supposed to be a suggestive language, right? Personal feeling or put the configuration file is better, after all, hard code this thing is not good maintenance, long time may not know where to write. I am more curious is this hint of text will not be a lot of it, can be loaded when the extent of the burden? If let me do, I will put the configuration file or write a separate file to load on demand, later maintenance is very convenient.

Which day needs you to do international processing ...
This thing is best encapsulated in a resource file.

As far as possible to separate the logic and resources, copy belongs to the resources, access and display belong to logic, this kind of follow-up development comfortable many

You said this kind of copy and pictures, videos and other no difference, should be summed up as resources management, how to manage to see the project needs. Large section of the text is generally used CMS, which is why most open source products are CMS or include CMS reasons. If it is a small paragraph of text usually consider the use of internationalization of this solution, is the use of specialized language files, such as the use of PO this way, and the use of specialized poedit and other software to manage such files.

If you think this is not worth it, you can consider the configuration file, the appropriate use of the cache does not lead to any performance loss, your profile can be more than the journey to a long time? Even 10M is not used.

  • 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.