PHP class instantiation. To use or not to use the parentheses? [closed]

They are equivalent. If you are not coding by any code convention, use which you like better. Personally, I like to leave it out, as it is really just clutter to me.


$foo = new bar() would be useful over $foo = new bar if you were passing arguments to the constructor. For example:

class bar {

    public $user_id;

    function __construct( $user_id ) {
        $this->user_id = $user_id
    }
}

-

$foo = new bar( $user_id );

Aside from that, and as already mentioned in the accepted answer, there is no difference.