Jump to content

[SOLVED] What is this "->"


tqla

Recommended Posts

It is used in what is called a Class

 

class Dog {
    public $name = "Roger";
    public $color = "brown";
    function bark() {
       echo "Woof";
    }
    function growl() {
       echo "GRRRRrrr";
    }
    function showName() {
       echo $this->name;
    }
}
$myDog = new Dog();
$myDog->bark();
$myDog->growl();
$myDog->showName();   //This echoes Roger
$myDog->name = "Jesus";
$myDog->showName(); // This echoes Jesus
echo $myDog->color;

Link to comment
https://forums.phpfreaks.com/topic/141722-solved-what-is-this/#findComment-741911
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.