class - PHP: what is the difference between $object::method and $object->method? -
i write:
$object->method but see:
$object::method what's difference?
-> used when referring member of object.
:: scope resolution operator , used refer static member of class. example
class test { public static function vehicle() { echo "bus"; } public function automobile() { echo "car"; } } you call function automobile() as
$test = new test(); $test->automobile(); and call vehicle function
test::vehicle();
Comments
Post a Comment