3v4l.org

run code in 500+ PHP versions simultaneously
<?php class User { public function __construct(public readonly string $name) {} public function say() { echo $this->name, PHP_EOL; } } class Student extends User { // } function listAll(User ...$users) { array_map( callback: fn(User $user) => $user->say(), array: $users ); } $users = [ new User('Jhon'), new User('Jane'), new Student('Bob'), // Child Student Class works. //'not User Class', // passing anything other than class User will throw TypeError. ]; listAll(...$users);
Output for git.master, git.master_jit
Jhon Jane Bob

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
58.05 ms | 731 KiB | 4 Q