3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Post { protected $title; protected $text; protected $filters; function __construct($title, $text, $filters) { $this->title = $title; $this->text = $text; $this->filters = $filters; } function get_title() { return htmlspecialchars($this->title); } function display_post() { $text = htmlspecialchars($this->text); foreach ($this->filters as $filter) $text = $filter->filter($text); return $text; } function __destruct() { // debugging stuff $s = "<!-- POST " . htmlspecialchars($this->title); $text = htmlspecialchars($this->text); foreach ($this->filters as $filter) $text = $filter->filter($text); $s = $s . ": " . $text; $s = $s . " -->"; echo $s; } }; echo unserialize(serialize(new Post("huehuehue i repor u", "brshrekt", Array())));
Output for git.master, git.master_jit, rfc.property-hooks
<!-- POST huehuehue i repor u: brshrekt --><!-- POST huehuehue i repor u: brshrekt --> Fatal error: Uncaught Error: Object of class Post could not be converted to string in /in/oQkLi:35 Stack trace: #0 {main} thrown in /in/oQkLi on line 35
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:
41.42 ms | 401 KiB | 8 Q