3v4l.org

run code in 300+ PHP versions simultaneously
<?php function handle(Post ...$posts) { foreach ($posts as $post) { print_r($post) . PHP_EOL; } } class Post { private $id; public function __construct($id) { $this->id = $id; } } class CoolPost extends Post { } $posts = [ 'string', null, ['array'], new Post(1), new stdClass(), new CoolPost(2), ]; try { handle(...$posts); } catch (Exception $e) { echo 'Exception: ' . $e->getMessage() . PHP_EOL; } catch (Error $e) { echo 'Error: ' . $e->getMessage() . PHP_EOL; }
Output for git.master_jit, git.master, rfc.property-hooks
Error: handle(): Argument #1 must be of type Post, string given, called in /in/TTQUY on line 37

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:
63.56 ms | 401 KiB | 8 Q