note 71031 added to language.oop5.autoload

From: Date: Thu, 09 Nov 2006 07:23:40 +0000
Subject: note 71031 added to language.oop5.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-119537@lists.php.net to get a copy of this message
Here is the most complete version of __autoload exception i guess. The best thing is that it can throw any exception plus the exception is fully functional. <?php class AutoloadException extends Exception { } class AutoloadExceptionRetranslator extends Exception { public function __construct($serializedException) { throw unserialize($serializedException); } } function __autoload($classname) { if(!file_exists($classname)) { $autoloadException = serialize(new AutoloadException("Class $classname could not be found")); return eval(" class $classname { function __construct(\$a=0, \$b=0, \$c=0, \$d=0, \$e=0, \$f=0, \$g=0, \$h=0, \$i=0) { throw new AutoloadExceptionRetranslator('$autoloadException'); } } "); } else { require_once $classname; } } try { $anyObject = new AnyNonExistantClass(); } catch (AutoloadException $e) { print_r($e->getTrace()); } ?> ---- Server IP: 193.219.81.76 Probable Submitter: 212.122.76.73 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php Edit -- https://master.php.net/note/edit/71031 Del: integrated -- https://master.php.net/note/delete/71031/integrated Del: useless -- https://master.php.net/note/delete/71031/useless Del: bad code -- https://master.php.net/note/delete/71031/bad+code Del: spam -- https://master.php.net/note/delete/71031/spam Del: non-english -- https://master.php.net/note/delete/71031/non-english Del: in docs -- https://master.php.net/note/delete/71031/in+docs Del: other reasons-- https://master.php.net/note/delete/71031 Reject -- https://master.php.net/note/reject/71031 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119537) next »