/    Sign up×
Community /Pin to ProfileBookmark

Which one is better & why ?

Hello forums !!
I would like to know a few things about OOP.
Which one is better ?
1>

[code=php]class A{
var $a;
var $b;
function A(){
$this->a = array();
$this->b = 10;
}
}[/code]

2>

[code=php]class A{
var $a = array();
var $b = 10;
function A(){

}
}[/code]

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.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderMar 27.2008 — http://phpbuilder.com/board/showthread.php?goto=lastpost&t=10352832

:p[/QUOTE]


So that's where all the cool kids are?
Copy linkTweet thisAlerts:
@NogDogMar 28.2008 — Nobody ever accused me of being cool, and I sure ain't a kid any more. ?
Copy linkTweet thisAlerts:
@MrCoderMar 28.2008 — Nobody ever accused me of being cool, and I sure ain't a kid any more. ?[/QUOTE]

Your only as old as the women you feel ?
×

Success!

Help @PHPycho spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...