note 84853 added to language.oop5.autoload
| From: | matias dot cohen at gmail dot com | Date: | Fri, 01 Aug 2008 23:33:53 +0000 |
| Subject: | note 84853 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143035@lists.php.net to get a copy of this message | ||
Another way of throwing exceptions inside an __autoload() function:
<?php
function myExceptionHandler($e) {
// Add code here
}
set_exception_handler('myExceptionHandler');
function __autoload($class) {
if (class_exists($class, false) || interface_exists($class, false)) {
return;
}
try {
@require_once('path/to/' . $class . '.php');
if (!class_exists($class, false) || !interface_exists($class, false)) {
throw new Exception('Class ' . $class . ' not found');
}
}
catch (Exception $e) {
myExceptionHandler($e);
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 190.136.239.16
----
Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/84853
Del: integrated -- https://master.php.net/note/delete/84853/integrated
Del: useless -- https://master.php.net/note/delete/84853/useless
Del: bad code -- https://master.php.net/note/delete/84853/bad+code
Del: spam -- https://master.php.net/note/delete/84853/spam
Del: non-english -- https://master.php.net/note/delete/84853/non-english
Del: in docs -- https://master.php.net/note/delete/84853/in+docs
Del: other reasons-- https://master.php.net/note/delete/84853
Reject -- https://master.php.net/note/reject/84853
Search -- https://master.php.net/manage/user-notes.php