3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Student { private $name; public function __construct(string $name) { $this->name = $name; } public function getName(): string { return $this->name; } } class Secretary { private $students = []; public function addStudent(Student $s): Secretary { array_push($this->students, $s); return $this; } public function getStudents(): array { return $this->students; } } $s = new Secretary(); $s->addStudent(new Student('Foo')); var_dump($s->getStudents());

preferences:
23.57 ms | 405 KiB | 5 Q