3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Example { private $variable; public function __construct($variable) { $this->variable = fopen('php://memory', 'rw+'); fwrite($this->variable, $variable); } public function example() { return file_get_contents($this->variable); } public function setExample($variable) { fwrite($this->variable, $variable); } public function __destruct() { fclose($this->variable); } } $example = new Example('first'); print $example->example() . PHP_EOL; $example->setExample('second'); print $example->example() . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: file_get_contents(): Argument #1 ($filename) must be of type string, resource given in /in/sn6ed:15 Stack trace: #0 /in/sn6ed(15): file_get_contents(Resource id #5) #1 /in/sn6ed(31): Example->example() #2 {main} thrown in /in/sn6ed on line 15
Process exited with code 255.

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:
70.5 ms | 401 KiB | 8 Q