3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class IOException extends Exception { protected $path; protected $mode; public function __construct($path, $mode, $message) { parent::__construct($message); $this->path = $path; $this->mode = $mode; } public function getPath() { return $this->path; } } class File { protected $path; protected $handle; protected $mode; public function __construct($path) { $this->path = $path; } public function open($mode) { $this->handle = @fopen($this->path, $mode); if (!$this->handle) { throw new IOException( $this->path, $mode, "could not open the file"); } $this->mode = $mode; } } $file = new File("/no/file"); try { $file->open("r"); } catch (IOException $io) { printf( "Exception occured opening %s\n", $io->getPath()); var_dump($io); } ?>
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Exception occured opening /no/file object(IOException)#2 (9) { ["path":protected]=> string(8) "/no/file" ["mode":protected]=> string(1) "r" ["message":protected]=> string(23) "could not open the file" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/JDHTi" ["line":protected]=> int(29) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/JDHTi" ["line"]=> int(39) ["function"]=> string(4) "open" ["class"]=> string(4) "File" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(1) "r" } } } ["previous":"Exception":private]=> NULL }
Output for hhvm-3.10.0 - 3.12.0
Exception occured opening /no/file object(IOException)#2 (9) { ["path":protected]=> string(8) "/no/file" ["mode":protected]=> string(1) "r" ["message":protected]=> string(23) "could not open the file" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/JDHTi" ["line":protected]=> int(30) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/JDHTi" ["line"]=> int(39) ["function"]=> string(4) "open" ["class"]=> string(4) "File" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(1) "r" } } } ["previous":"Exception":private]=> NULL }
Output for 5.0.0 - 5.0.2, 5.0.5 - 5.2.17
Exception occured opening /no/file object(IOException)#2 (8) { ["path:protected"]=> string(8) "/no/file" ["mode:protected"]=> string(1) "r" ["message:protected"]=> string(23) "could not open the file" ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(9) "/in/JDHTi" ["line:protected"]=> int(29) ["trace:private"]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/JDHTi" ["line"]=> int(39) ["function"]=> string(4) "open" ["class"]=> string(4) "File" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(1) "r" } } } }
Output for 5.0.3 - 5.0.4
Exception occured opening /no/file object(IOException)#2 (8) { ["path:protected"]=> string(8) "/no/file" ["mode:protected"]=> string(1) "r" ["message:protected"]=> string(23) "could not open the file" ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(9) "/in/JDHTi" ["line:protected"]=> int(29) ["trace:private"]=> array(2) { [0]=> array(5) { ["file"]=> string(9) "/in/JDHTi" ["line"]=> int(29) ["function"]=> string(4) "open" ["class"]=> string(4) "File" ["type"]=> string(2) "::" } [1]=> array(6) { ["file"]=> string(9) "/in/JDHTi" ["line"]=> int(39) ["function"]=> string(4) "open" ["class"]=> string(4) "File" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(1) "r" } } } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/JDHTi 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_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/JDHTi on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/JDHTi on line 3
Process exited with code 255.