Forum Moderators: coopster
}
}[/PHP]
In both cases there is initialization of default values in properties.
I would like to know which one is better to initialize the default values and why ?
Thanks in advance for the Suggestion.
As I work with a lot of different groups of programmers some use your first method, others use your second method. I have never noticed a difference in either method, although I have not specifically checked execution time.
The examples in the manual actually use both methods. From the php4 manual -
/* This is how it should be done. */
class Cart {
var $todays_date;
var $name;
var $owner;
var $items = array("VCR", "TV");function Cart() {
$this->todays_date = date("Y-m-d");
$this->name = $GLOBALS['firstname'];
/* etc. . . */
}
}