Use include or constants to get codes?

3

I created a file containing patterns that are used on my system. I would like to know what is the difference in performance between calling the code by a include or a constante like this:

//código do incluir.php: <a href=""></a>

include "incluir.php";
define('_CONSTANT','<a href=""></a>');

Do you have any advantage in using both of them?

I ask this because I am in doubt if I use one or the other can affect the performance of my system, since I use this a lot to get standard codes

    
asked by anonymous 09.02.2016 / 18:15

1 answer

3

The question is very objective about which of the two is more performative. So I will not comment on concepts or data structure (mvc, oop, etc) or even good programming practices.

Responding objectively, within its context, is faster defining by constants. Simple as that.

The reason is obvious. The process of including a file consumes memory and runtime to load an even value that would be in a constant. So if you can use the constants, use them.

    
09.02.2016 / 20:56