Which one is better & why ?
Posted: Thu Mar 27, 2008 3:42 am
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hello forums !!
I would like to know a few things about OOP.
Which one is better ?
1>
2>
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.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hello forums !!
I would like to know a few things about OOP.
Which one is better ?
1>
Code: Select all
class A{
var $a;
var $b;
function A(){
$this->a = array();
$this->b = 10;
}
}Code: Select all
class A{
var $a = array();
var $b = 10;
function A(){
}
}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.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: