Hello Nilesh, So could you illustrate a bit the __construct() function, please? Should I pass those variables as parameters of that function? And what if I need to change their values?) Thanks! -- With best regards from Ukraine, Andre Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule ----- Original message ----- From: Nilesh Govindarajan <lists@xxxxxxxxxx> To: php-general@xxxxxxxxxxxxx <php-general@xxxxxxxxxxxxx> Date: Saturday, May 1, 2010, 8:16:37 PM Subject: A stupid question about classes On 05/01/2010 10:23 PM, Andre Polykanine wrote: > Hello everyone, > Just a basic question. > I have my class starting like this: > > Class OireMail { > // these are required > public $smtp_server=""; > public $domain=""; > public $from=""; > public $login=""; > public $pass=""; > > And then go the function themselves. > I was told that it's better to put the initial variables in the > __construct() function. What are the advantages of doing that and if I > need to do it, how would I call the class from another file then? > Thanks! > The advantages of initializing the variables in __construct() is that whenever an object of the class is created, the variables have the values you expect. If you don't put them in __construct(), you will have to create another method which will have to be called after you have created the object using the new operator. Ultimately its the same thing, __construct() is called automatically, only that's the difference. -- Nilesh Govindarajan Site & Server Administrator www.itech7.com ???? ???? ???? ! ?? ????: ?????? ???? ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php