- var_dump: documentation ( source)
- printf: documentation ( source)
- fopen: documentation ( source)
<?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);
}
?>