How does the "->" operator relate to object-oriented programming in PHP?
The "->" operator is used in PHP to access properties and methods of an object in object-oriented programming. It is used to call a method or access a property of an object instance. This operator is essential for interacting with objects in PHP and is a fundamental part of object-oriented programming.
class Person {
public $name;
public function greet() {
echo "Hello, my name is " . $this->name;
}
}
$person = new Person();
$person->name = "John";
$person->greet();