Wow, I have started migrating some of my scripts over and decided to completely rebuild from the ground up, and I must say - I am in love the error handling, it is sooo good that I find myself overusing it
...
How can you not love PHP5?...
PHP Code:
<?php
class xmlException extends Exception {
function __construct() { //print_r($this); }
};
class xml extends DOMDocument {
public function __construct( ) {
parent::__construct();
}
public function loadFile($file) {
try {
self::fileExists($file);
parent::load($file);
return true;
} catch (xmlException $e) {
// File Not Found
return false;
}
}
public function saveFile($file) {
try {
self::fileDoesExist($file);
parent::save($file);
return true;
} catch (xmlException $e) {
// File Exists
return false;
}
}
private function fileExists($file) {
if (!file_exists($file)) throw new xmlException();
}
private function fileDoesExist($file) {
if (!file_exists($file)) throw new xmlException();
}
}
?>
edit:
Quiz,
I threw in 2 sneaky little syntax errors, try find it..
Bookmarks