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 serialize(new Post("huehuehue i repor u", new SplFileObject("/home/daedalus/flag.txt"), Array()));
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught RuntimeException: SplFileObject::__construct(): open_basedir restriction in effect. File(/home/daedalus/flag.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Ds6b4:35 Stack trace: #0 /in/Ds6b4(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/Ds6b4 on line 35
Process exited with code 255.
Output for 8.0.13
Fatal error: Uncaught RuntimeException: SplFileObject::__construct(/home/daedalus/flag.txt): Failed to open stream: Permission denied in /in/Ds6b4:35 Stack trace: #0 /in/Ds6b4(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/Ds6b4 on line 35
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.33
Fatal error: Uncaught RuntimeException: SplFileObject::__construct(/home/daedalus/flag.txt): failed to open stream: Permission denied in /in/Ds6b4:35 Stack trace: #0 /in/Ds6b4(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/Ds6b4 on line 35
Process exited with code 255.
Output for 5.6.0 - 5.6.38
Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(): open_basedir restriction in effect. File(/home/daedalus/flag.txt) is not within the allowed path(s): (/tmp:/in:/etc)' in /in/Ds6b4:35 Stack trace: #0 /in/Ds6b4(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/Ds6b4 on line 35
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(/home/daedalus/flag.txt): failed to open stream: No such file or directory' in /in/Ds6b4:35 Stack trace: #0 /in/Ds6b4(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/Ds6b4 on line 35
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Invalid argument supplied for foreach() in /in/Ds6b4 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/Ds6b4:35 Stack trace: #0 /in/Ds6b4(35): SplFileObject->__construct('/home/daedalus/...') #1 {main} thrown in /in/Ds6b4 on line 35
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Class 'SplFileObject' not found in /in/Ds6b4 on line 35 Warning: Invalid argument supplied for foreach() in /in/Ds6b4 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/Ds6b4 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Ds6b4 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/Ds6b4 on line 3
Process exited with code 255.

preferences:
324.6 ms | 401 KiB | 418 Q