3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Author { private $name; private $id; public function __construct($id, $name = null) { $this->id = $id; $this->name = null; } public function name() { return $this->name; } public function setName($name) { $this->name = $name; } public function id() { return $this->id; } public function __call($name, $value) { echo 'we dont have all the pieces, look em up'; die; } } class Post { private $id; private $title; private $body; private $author; public function __construct($id, $title, $body, $author) { $this->id = $id; $this->title = $title; $this->body = $body; $this->author = $author; } public function id() { return $this->id; } public function title() { return $this->title; } public function setTitle($title) { $this->title = $title; } public function author() { return $this->author; } public function setAuthor(Author $author) { $this->author = $author; } } $post = new Post(111, 'A Song of Ice and Fire', 'My book is the shiz', new Author(222, 'George RR Martin')); echo $post->author()->name;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Cannot access private property Author::$name in /in/nBkH7:78 Stack trace: #0 {main} thrown in /in/nBkH7 on line 78
Process exited with code 255.

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