3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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;
based on bGf5k
Output for 5.4.0 - 7.1.7
Warning: file_get_contents() expects parameter 1 to be a valid path, resource given in /in/sn6ed on line 15 Warning: file_get_contents() expects parameter 1 to be a valid path, resource given in /in/sn6ed on line 15
Output for 5.2.14 - 5.2.17, 5.3.3 - 5.3.29
Warning: file_get_contents() expects parameter 1 to be string, resource given in /in/sn6ed on line 15 Warning: file_get_contents() expects parameter 1 to be string, resource given in /in/sn6ed on line 15
Output for 5.1.4 - 5.2.13, 5.3.0 - 5.3.2
Strict Standards: Redefining already defined constructor for class Example in /in/sn6ed on line 13 Warning: file_get_contents() expects parameter 1 to be string, resource given in /in/sn6ed on line 15 Warning: file_get_contents() expects parameter 1 to be string, resource given in /in/sn6ed on line 15
Output for 5.0.2 - 5.1.3
Strict Standards: Redefining already defined constructor for class Example in /in/sn6ed on line 13 Warning: fopen(php://memory): failed to open stream: Inappropriate ioctl for device in /in/sn6ed on line 9 Warning: fwrite(): supplied argument is not a valid stream resource in /in/sn6ed on line 10 Warning: fwrite(): supplied argument is not a valid stream resource in /in/sn6ed on line 20 Warning: fclose(): supplied argument is not a valid stream resource in /in/sn6ed on line 25
Output for 5.0.0 - 5.0.1
Strict Standards: Redefining already defined constructor for class Example in /in/sn6ed on line 13 Warning: fopen(php://memory): failed to open stream: Inappropriate ioctl for device in /in/sn6ed on line 9 Warning: fwrite(): supplied argument is not a valid stream resource in /in/sn6ed on line 10 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sn6ed on line 31 PHP_EOL Warning: fwrite(): supplied argument is not a valid stream resource in /in/sn6ed on line 20 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sn6ed on line 33 PHP_EOL Warning: fclose(): supplied argument is not a valid stream resource in /in/sn6ed on line 25
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/sn6ed on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CLASS in /in/sn6ed on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/sn6ed on line 3
Process exited with code 255.