How is "->" used in object-oriented programming in PHP?
In object-oriented programming in PHP, the "->" symbol is used to access methods and properties of an object. This is known as the object operator. By using "->", you can call methods or access properties of an object within a class. Example:
class Car {
public $color;
public function setColor($newColor) {
$this->color = $newColor;
}
public function getColor() {
return $this->color;
}
}
$myCar = new Car();
$myCar->setColor("blue");
echo $myCar->getColor(); // Output: blue