What does "->" signify in PHP code?
In PHP, the "->" symbol is used to access methods and properties of an object. It is called the object operator and is used to reference a specific instance of a class. When using "->", you are essentially telling PHP to look inside the object for the specified method or property. Example:
class Person {
public $name;
public function __construct($name) {
$this->name = $name;
}
public function greet() {
echo "Hello, my name is " . $this->name;
}
}
$person = new Person("John");
$person->greet();