Possible Duplicate:
Instantiate a class with or without parentheses?
This is a minor quibble, but is there any reason to prefer
$obj = new SomeClass();
over
$obj = new SomeClass;
I prefer the latter because I like how it looks, and it saves you a couple of characters. On the downside, it goes against conventions and makes it slightly harder to come back and add an argument later.
Anyone have a compelling argument for either, or is this pure semantics?
Doesn't matter as long as your code is consistent, conventional & clear.
The parentheses are for passing arguments into __construct. Just keep one style, and follow it, unless you have to pass arguments into classes.
Of course, you could just go for the new class; format until you need new classtwo($one, $two). That might be a little inconsistent at first, but it'll make sense in the long run.
Though, pure semantics. Just that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With