Forum Moderators: coopster

Message Too Old, No Replies

questions about config.php

         

PHPycho

6:32 am on Apr 12, 2007 (gmt 0)

10+ Year Member



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

phparion

6:51 am on Apr 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would prefer to make a class for database connection, and whenever need db connection , create object, send database type the class should call related function to connect..

this way I would be able to connect to oracle, mysql, sql, access etc etc just by one class and can reuse this class in my all projects

jatar_k

12:19 pm on Apr 12, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



to be honest it is more about personal preference than anything else

just make sure that config is above of the web root