tags:

views:

35

answers:

3
class test {
    public $isNew;
    public function isNew(){}
}

$ins = new test();
$ins->isNew

Here,how does php parse $ins->isNew?

+2  A: 

$ins->isNew is the variable. $ins->isNew() is the function.

dnagirl
+1  A: 

See the chapter on Class Basic in the PHP manual:

$ins->isNew   // class member
$ins->isNew() // class method
Gordon
+1  A: 

PHP is not a functional programming language where functions are also data. So $ins->isNew wouldn’t be ambiguous to either refer to the method isNew or the attribute isNew. $ins->isNew is always an attribute and $ins->isNew() a method call.

Gumbo