3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyStreamWrapper { static $counter = 1; private $id; public function __construct() { $this->id = self::$counter++; } public function stream_open($path, $mode, $options, &$opened_path) { echo "({$this->id}) stream_open()\n"; return true; } public function stream_write($data) { echo "({$this->id}) stream_write()\n"; return \strlen($data); } public function stream_flush() { echo "({$this->id}) stream_flush()\n"; return true; } public function stream_close() { echo "({$this->id}) stream_close()\n"; return true; } public function __destruct() { echo "({$this->id}) __destruct()\n"; } } \stream_wrapper_register('test', MyStreamWrapper::class); if (($handle = \fopen('test:///foobar', 'r+')) === false) { throw new \RuntimeException("Failed to open file"); } if (\fwrite($handle, 'test') === false) { throw new \RuntimeException("Failed to write to file"); } if (\fclose($handle) === false) { throw new \RuntimeException("Failed to close file"); } if (($handle2 = \fopen('test:///blubb', 'r+')) === false) { throw new \RuntimeException("Failed to open file"); } if (\fwrite($handle2, 'test') === false) { throw new \RuntimeException("Failed to write to file"); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property MyStreamWrapper::$context is deprecated in /in/CMItP on line 46 (1) stream_open() (1) stream_write() (1) stream_flush() (1) stream_close() (1) __destruct() Deprecated: Creation of dynamic property MyStreamWrapper::$context is deprecated in /in/CMItP on line 58 (2) stream_open() (2) stream_write() (2) __destruct() (2) stream_flush() (2) stream_close()

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