@ 2013-12-07T01:22:50Z <?php
class IOException extends Exception {
protected $file;
public function __construct($file, $message) {
parent::__construct($message);
$this->file = $file;
}
public function getPath() {
return $this->file;
}
}
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);
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Type of IOException::$file must be string (as in class Exception) in /in/atUmE on line 2
Process exited with code 255 . Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 Exception occured opening /no/file
object(IOException)#2 (7) {
["file":protected]=>
string(8) "/no/file"
["message":protected]=>
string(23) "could not open the file"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["line":protected]=>
int(26)
["trace":"Exception":private]=>
array(1) {
[0]=>
array(6) {
["file"]=>
string(9) "/in/atUmE"
["line"]=>
int(34)
["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.1.0 - 5.1.6 , 5.2.0 - 5.2.17 Exception occured opening /no/file
object(IOException)#2 (6) {
["file:protected"]=>
string(8) "/no/file"
["message:protected"]=>
string(23) "could not open the file"
["string:private"]=>
string(0) ""
["code:protected"]=>
int(0)
["line:protected"]=>
int(26)
["trace:private"]=>
array(1) {
[0]=>
array(6) {
["file"]=>
string(9) "/in/atUmE"
["line"]=>
int(34)
["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 (6) {
["file:protected"]=>
string(8) "/no/file"
["message:protected"]=>
string(23) "could not open the file"
["string:private"]=>
string(0) ""
["code:protected"]=>
int(0)
["line:protected"]=>
int(26)
["trace:private"]=>
array(2) {
[0]=>
array(5) {
["file"]=>
string(9) "/in/atUmE"
["line"]=>
int(26)
["function"]=>
string(4) "open"
["class"]=>
string(4) "File"
["type"]=>
string(2) "::"
}
[1]=>
array(6) {
["file"]=>
string(9) "/in/atUmE"
["line"]=>
int(34)
["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/atUmE on line 3
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/atUmE 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/atUmE on line 3
Process exited with code 255 . preferences:dark mode live preview
270.13 ms | 401 KiB | 384 Q