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.

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


Thursday, May 6, 2004, 7:56:01 AM, thus was written:
> First off thanks Curt for the attempt at explaining what the purpose was for
> those, I'm convinced enough to start doing that since that's what the "pros"
> use. :)

> However, I know have another concern. As for as class security. Is it wrong
> to initialize the static variables for my database assignment class ie..

> [..Example..]

> <?php
> class db_connection {
>       var $user = "dbuser";
>       var $pass = "dbpass";
>       var $db = "db";
>       var $host = "localhost";
>       var $connection;
....?>>

> [../Example..]


> or should I still be using the normal seperate file for those values ie...

> [..Example2..]

> <?php
> include_once("dbconn.php");
> class db_connection {
>       var $user;
>       var $pass;
>       var $db;
>       var $host;
>       var $connection;

...?>>

> [../Example..]

> Where in the included file I have the variables listed as
> $user = username;
> $pass = password;
> etc.....

> The Class files that I am creating are going to be seperate "template"
> includes if you will where they also are going to be "include_once()" items
> aswell. Is it over redundant to have both of the files includes?

> Any help is much appreciated as I'm still learning this exciting language!
> :)
> TIA,
> Wolf

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to