note 96678 deleted from language.oop5.autoload by danbrown

From: Date: Thu, 11 Mar 2010 13:51:02 +0000
Subject: note 96678 deleted from language.oop5.autoload by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166911@lists.php.net to get a copy of this message
Note Submitter: connec dot 2002 at SPAM dot ME dot NOT dot gmail dot com ---- An interesting gotcha in relation to using an autoloader to generate an exception instead of standard PHP errors is that it will fail if the class is called statically: <?php function autoload($class) { throw new Exception("No such class!"); } spl_autoload_register('autoload'); try { new NotAClass; }catch(Exception $e) { echo $e->getMessage(); // No such class! } try { NotAClass::method(); // Fatal error }catch(Exception $e) { echo $e->getMessage(); // [doesn't execute] } ?>

« previous php.notes (#166911) next »