3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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", new SplFileObject("/home/daedalus/flag.txt"), Array())));
based on Ds6b4
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught RuntimeException: SplFileObject::__construct(/home/daedalus/flag.txt): failed to open stream: No such file or directory in /in/OHEAt:35 Stack trace: #0 /in/OHEAt(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/OHEAt on line 35
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(/home/daedalus/flag.txt): failed to open stream: No such file or directory' in /in/OHEAt:35 Stack trace: #0 /in/OHEAt(35): SplFileObject->__construct() #1 {main}
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(/home/daedalus/flag.txt): failed to open stream: No such file or directory' in /in/OHEAt:35 Stack trace: #0 /in/OHEAt(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/OHEAt on line 35
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Warning: Invalid argument supplied for foreach() in /in/OHEAt on line 27 <!-- POST : --> Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(/home/daedalus/flag.txt): failed to open stream: No such file or directory' in /in/OHEAt:35 Stack trace: #0 /in/OHEAt(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/OHEAt on line 35
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Class 'SplFileObject' not found in /in/OHEAt on line 35 Warning: Invalid argument supplied for foreach() in /in/OHEAt on line 27 <!-- POST : -->
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/OHEAt on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/OHEAt on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/OHEAt on line 3
Process exited with code 255.