Possible Duplicate:
Reference - What does this symbol mean in PHP?
Sorry for being so pedantic about this, but I'm confused about the object operator (->). What exactly is it doing and how (to avoid errors and misusing) do I use it?
In order to use the object operator, you will need to create and instantiate a class, as follows:
class MyClass {
public $myVar;
public function myMethod() {
}
}
$instance = new MyClass();
$instance->myVar = "Hello World"; // Assign "Hello World" to "myVar"
$instance->myMethod(); // Run "myMethod()"
Let me explain the above code:
The object operator is simply PHPs way of accessing, running, or assigning "stuff" within an object.
Hope that helps.
its just like the . in other languages. eg, if you have a object called ball with method bounce(), in most languages it would be
ball.bounce();
in php it is
ball->bounce();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With