Hello forums
We all know its effective to create one central config file say "config.php"
that contains the required configuration variables .
I had seen the configuration is done by three ways
1> By simply using variables ex $dbHost = ""; etc
2> By using associative arrays ex $setting['dbHost'] = ""; etc
3> By defining constants ex define("DB_HOST",""); etc

My Question ?
Which one to use and why in config.php for creating the configuration file?
Thanks in advance to all of you

    If a value is intended to be constant (the script should never have to change it), then I prefer to define() a constant. Besides being what constants are designed for, they are also automatically in the global scope, and as such can be referenced from within any function as well as within the main body of your script.

      I agree with above comment.
      In addition, the second method is perhaps done to make globalizing them easier too.

        Write a Reply...