Reputation: 321
What will be the performance impact of defining multiple PHP CONSTANTS. I want to add all the string messages in one file. Shall I define all the strings as constants?
Upvotes: 2
Views: 724
Reputation:
Main purpose to have CONSTANTS
is to store your fixed value. So there is no harm in storing more values in CONSTANT
.
If you are really worried about performance then you should store your CONSTANT in APC cache
.
Define Constant: http://php.net/manual/en/function.apc-define-constants.php
Load Defined Constants: http://php.net/manual/en/function.apc-load-constants.php
If we go deep one more step then you can use memcache or redis to store your strings in key value pair and fetch from there when required.
Upvotes: 3