Learning PHP but I've noticed the writer of the book I'm using calls objects in 2 different ways [duplicate]
Possible Duplicate:
PHP class instantiation. To use or not to use the parenthesis?
I'm learning PHP from an O'reilly book "Learning PHP, MySQL and Javascript". I'm half way through learning a开发者_开发知识库bout objects etc.
I've noticed that sometimes the writer calls objects in two different ways.
$example = new Object
$example = new Object()
They both seem to work fine for me. Is there a preferred way or best practice? Is there a reason for this?
Personally I prefer to include the parenthesis. helps to remind you the constructor is a method that you can override.
But this could just be because I learned OOP in C++.
Whatever you do, just be consistent.
精彩评论