In PHP, how do I iterate over objects in vanilla PHP?

PHP, iterate, objects, foreach, example, vanilla PHP
This example demonstrates how to iterate over an object in PHP using the foreach loop.
<?php class Person { public $name; public $age; public function __construct($name, $age) { $this->name = $name; $this->age = $age; } } $person1 = new Person("John", 30); $person2 = new Person("Jane", 25); $people = [$person1, $person2]; foreach ($people as $person) { echo "Name: " . $person->name . ", Age: " . $person->age . "<br>"; } ?>

PHP iterate objects foreach example vanilla PHP