i would like to know the difference between this two methods for initializing the object of a class
Method 1 (Using Scope resolution operator) :
Test::foo();
Method 2 (creating an instance of an object):
$test = new Test;
$test->foo();
also what is this -> operator called?
Test::foo()is merely statically calling a method of a class, it doesn’t do anything with objects. It might initialize static values in the class, but you don’t usually use static initializers. A static initializer may be used internally in the case of Singletons, but you should never call a public static initializer like this.$test = new Testis actually instantiating an object, in which process it is likely initialized.Please note the difference between initialize (setting up the initial state of an object/class/variable) and instantiate (create an object instance from a class).
->is theT_OBJECT_OPERATOR.