Say I have the following:
function __autoload($class) {
if(file_exists("{$_SERVER['DOCUMENT_ROOT']}/etc/".strtolower($class).".php")) {
require_once strtolower($class).".php";
return true;
} else {echo "failed";}
}
class test {
public function __construct() {
$this->db = new Database();
$this->auth = new Authentications();
}
}
$t = new test();
The file authentications.php
does not exist. However I want to be able to handle that gracefully, at the moment I get the following output:
failed Fatal error: Class 'Authentications' not found in core.php on line 15
How can I handle this gracefully? I want to be able to output my own error or carry on - whichever I choose.