"Richard Harb" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > More often than not it's a good thing to assign 'default' values to > class variables like that. > > In this case though I've observed that common practice is to get the > user/pass values from a config file and pass them along as variables > when creating an instance of the class.
I'm defining things like DB access values as constants in my config file rather than as global variables. This way I can make absolutely sure that they are not accidently changed anywhere in my application. As constants are globally available you don't need to pass them to every class method that is using them. <?php class db_connection { var $user = CONFIG_DB_USER; var $pass = CONFIG_DB_PASSWORD; var $db = CONFIG_DB_NAME; var $host = CONFIG_DB_HOST; var $connection; ....?> Regards, Torsten > > Classes are most beneficial if you can take your class include file > from one project to the next and just pass along different parameters > and they work. Including user/pass would force you to edit/change > those values on every project you use that class in. > > HTH > Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php