Welcome Guest, Not a member yet? Register   Sign In
Why vars to constants in index.php?
#1

[eluser]JCianflone[/eluser]
Hey everyone,

So, I've had some time to tinker with my install of codeigniter and I was looking for ways to optimize my own install and I was wondering about the index.php file. We've got a whole bunch of variables that just get loaded into constants down below (I know there is more going on, in some cases just bare with me). I'm really just wondering why it's done this way. Since there is no computation going on in these variables, constants should be faster to use. Just take as an example the $system_path or the $application_folder. Am I missing something here? Is there a reason these are variables?

Thanks!
#2

[eluser]Kindari[/eluser]
I think mainly to provide expandability. For example I know of some setups where multiple websites point to the same front loader, which has been modified to react to the different websites differently. Changing application path, maybe version, etc.
#3

[eluser]JCianflone[/eluser]
Hmm...maybe...but just look at the $system_path var for one second. The only place that is used is in the index.php file. By the time you get to the end of that file, that var is placed in BASEPATH and you'll never use or need $system_path again. The same goes for the APPPATH and $application_folder. I think if you had multiple websites pointing to the same front controller, you could just as easily set that up using a constant.




Theme © iAndrew 2016 - Forum software by © MyBB