Romisha Aggarwal
Romisha Aggarwal

Reputation: 321

Performance impact of defining multiple PHP CONSTANTS

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

Answers (1)

user4094161
user4094161

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

Related Questions