What are the benefits of using arrays to define constants?

Source: Internet
Author: User
What are the benefits of defining constants with arrays?
This post was last edited by Tp_2015_1 on 2015-05-22 21:29:28

See the figure in the way an array to define constants, always feel so much trouble ah, why not directly write a constant, such as
Define (' Attach_malbum ', ' shop/member ');
How good is that?
The whole array of trouble, incredibly.
Even more exasperating is the image of the array in other files redefined again, this is not to eat one more swoop?
Why not have a direct, this group of people are not enough to support
Define (' Shop_site_url ', $config [' Shop_site_url ']);

------to solve the idea----------------------
There are some benefits:
1, the simple polymerization effect
2, since the configuration, it is possible to dynamically modify, such as many frameworks can dynamically modify configuration items.
3, there may be a need to get all the configuration, due to the aggregation of the array, it is also easy to view all the configuration items.
------to solve the idea----------------------
Constants are defined and cannot be modified
$config Array, which identifies the array that is stored as configuration information
You can also define the $user array, which identifies the user information that this array holds
You want to get the user information, you know to find $user array, when you store too much data, and forget the key name, you can print out, at a glance
Especially when it's two development, it's not so painful to see so many variables you define.

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