Reputation: 33
I have the following code in script I implement and it does work correctly, just want to understand:
$variable1 = function1(); // function1 is a class method, it’s file included per require_once
$ variable1 -> function2(); // function2 is a class method, it’s file included per require_once
Isn’t -> here an object operator? But there is no initialized instance save in $variable1.
Help appreciated
Upvotes: 2
Views: 142
Reputation: 146310
That just means that function1()
returns an object.
Hence you can use that object and it's functions.
Example:
class Test {
function function2(){
echo "Hi";
}
}
function function1(){ return new Test; }
//SO:
$variable1 = function1();
$variable1->function2();
Upvotes: 6