3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MemoryFile { private static $data = ""; private static $pos = 0; public function stream_open() { self::$pos = 0; return true; } public function stream_read($count) { return substr(self::$data, (self::$pos += $count) - $count, $count); } public function stream_write($data) { self::$data = substr(self::$data, 0, self::$pos) . $data; self::$pos += strlen($data); return strlen($data); } public function stream_tell() { return self::$pos; } public function stream_eof() { return self::$pos >= strlen(self::$data); } public function stream_stat() { return []; } } stream_wrapper_register("foo", "MemoryFile"); file_put_contents("foo://bar", <<<'PHTML' <?php // view.phtml echo "<html><head><title>$this->data</title></head><body></body></html>"; PHTML ); // View.php class View { private $data = 'test'; public function render() { require 'foo://bar'; } } (new View)->render();
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property MemoryFile::$context is deprecated in /in/Qv730 on line 16 Deprecated: Creation of dynamic property MemoryFile::$context is deprecated in /in/Qv730 on line 29 Warning: require(): MemoryFile::stream_set_option is not implemented! in /in/Qv730 on line 29 <html><head><title>test</title></head><body></body></html>

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