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.