<?php
class Person {
private $name;
private $age;
public function __construct($name, $age) {
$this->name = $name;
$this->age = $age;
}
public function setName($name) {
$this->name = $name;
}
public function setAge($age) {
$this->age = $age;
}
public function getName() {
return $this->name;
}
public function getAge() {
return $this->age;
}
}
$person1 = new Person("John", 25);
$person2 = new Person("Jane", 30);
echo $person1->getName() . " is " . $person1->getAge() . " years old.<br>";
echo $person2->getName() . " is " . $person2->getAge() . " years old.<br>";
$person1->setAge(30);
echo $person1->getName() . " is now " . $person1->getAge() . " years old.<br>";
?>