Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When there are no arguments, we have these two options:

$obj = new MyClass;


$obj = new MyClass();

I always pick the former, just because.

Any thoughts?

share|improve this question
Duplicate from stackoverflow:… – Asaf Aug 31 '12 at 21:27
And also:… – Jack Sep 1 '12 at 1:43
You can't duplicate questions cross-network. Specific, answerable questions about coding standards/conventions are on-topic here. – user8 Sep 5 '12 at 12:45
However, given the existence of the question on Stack Overflow you have to wonder why felt the need to ask it here. – ChrisF Sep 5 '12 at 12:56
@ChrisF Oh I'm sorry. Next time I'll just read the entire internet to avoid bothering you with my "duplicate". – ChocoDeveloper Sep 6 '12 at 9:22
up vote 7 down vote accepted

Include them. It isn't much extra work and it won't confuse people that don't know that leaving them off the parenthesis is an option.

share|improve this answer
+1 I didn't know you could leave them off. It would have confused me! – MrMisterMan Sep 5 '12 at 13:03

Include them; with PHP, you want to be as specific and unambiguous as you can.

share|improve this answer
In ANY programming, you want to be as specific and unambiguous as you can. – Jeremy J Starcher Sep 1 '12 at 0:25
@JeremyJStarcher Though this isn't really ambiguous, just confusing for people who don't know about this optional syntax. – ChocoDeveloper Sep 1 '12 at 4:17
Yes, it's not really possible for one to be ambiguous in a programming language, as far as the computer is concerned, because it still knows what to do. Rather I meant that dropping little bits of unnecessary syntax here and there is a slippery slop of special cases that results in code that simply takes longer for other humans, or your future self, to understand. – Eliot Ball Sep 1 '12 at 10:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.