Source Code:
(back to article)
<?php class Person { public $name; public $age; public function __construct($name, $age) { $this->name = $name; $this->age = $age; } } $people = array( new Person("John", 25), new Person("Jane", 30), new Person("Jim", 35) ); foreach ($people as $person) { echo "Name: " . $person->name . ", Age: " . $person->age . "<br>"; } ?>
Result:
Report an issue