3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IOException extends Exception { protected $path; public function __construct($path, $message) { parent::__construct($message); $this->path = $path; } public function getPath() { return $this->path; } } class File { protected $path; protected $handle; 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, "could not open the file"); } } } $file = new File("/no/file"); try { $file->open("r"); } catch (IOException $io) { printf( "Exception occured opening %s\n", $io->getPath()); var_dump($io); } ?>

preferences:
39.71 ms | 402 KiB | 5 Q