Get and Set Methods
Getters and setters control access to class properties.
Example
Section titled “Example”class Product {
private float $price;
public function setPrice(float $price) { $this->price = $price; }
public function getPrice(): float { return $this->price; }}
$product = new Product();$product->setPrice(100);
echo $product->getPrice();