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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -