firstName = $first; $this->lastName = $last; $this->age = $age; Person::$total++; } function __destruct() { echo "Releasing " . $this->format() . "
\n"; Person::$total--; } function format() { return "{$this->firstName} {$this->lastName}, Age: {$this->age}"; } function setAge($age) { $this->age = $age; } static function total() { return Person::$total; } } class Student extends Person { private $advisor; function __construct($first, $last, $age, $advisor) { parent::__construct($first, $last, $age); $this->advisor = $advisor; } function format() { return parent::format() . ", Advisor: {$this->advisor}"; } } ?> OOP Demo format() . "
\n"; echo "Current Population Size = " . Person::total() . "

\n"; $loewe = new Person("Sebastian", "Loewe", 27); echo $loewe->format() . "
\n"; echo "Current Population Size = " . Person::total() . "

\n"; unset($loewe); echo "Current Population Size = " . Person::total() . "

\n"; $reddy = new Student("Sandeep", "Reddy", 19, "Paxton"); echo $reddy->format() . "
\n"; echo "Current Population Size = " . Person::total() . "

\n"; $student = clone $reddy; $student->setAge(20); echo $student->format() . "
\n"; echo "Current Population Size = " . Person::total() . "

\n"; try { throw new Exception("Mystery", 2006); } catch (Exception $e) { echo "Error Message: " . $e->getMessage() . "
\n"; echo "Error Number: " . $e->getCode() . "
\n"; echo "Error Line: " . $e->getLine() . "
\n"; echo "Error File: " . $e->getFile() . "

\n"; } ?>