Can overuse of constants affect system performance?

Asked

Viewed 49 times

1

I use quite a lot constantes in php to store information to configure the system

Example:

define('_CONFIG_SERVER','PC\SQLEXPRESS');
define('_CONFIG_DATA','Database');
define('_CONFIG_NAME','localhost');
define('_CONFIG_LANGUAGE_DEFAULT','pt-BR');

I use quite even... This can decrease the performance of the system???

I found a topical similar, but does not answer my question that in the case is the question of performance!

  • I think mentioning this To what extent premature optimization is a problem?, may be useful.

  • Kkkkkk liked the text, at the moment I’m just studying to just further start a project...in case the premature optimization is only when it’s done and tries to optimize-Ó? or if I use it first, it serves the same example? @Inkeliz

1 answer

3


Yes you can, but "overuse" would be defining thousands constants in each page load. Are you setting 20, 50, maybe even 100? So it’s probably irrelevant and trying to change that would be micro-optimization, there are countless other things infinitely more important to the performance of your code than something like this.

If you really are doing something really crazy with tons of constants you can try to take a look in this extent whose purpose is precisely to optimize the mass definition of constants.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.