names = $names; } public function greetAll() { $index = 0; while ($index < count($this->names)) { $name = $this->names[$index]; if (!empty($name)) { echo $this->greet($name) . " "; } $index++; } } private function greet($name) { return "Hello, " . $name . "!"; } } $names = ["Alice", "Bob", "Charlie"]; $greeter = new Greeter($names); $greeter->greetAll(); ?>