note 96678 added to language.oop5.autoload

From: Date: Thu, 11 Mar 2010 04:38:10 +0000
Subject: note 96678 added to language.oop5.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-166897@lists.php.net to get a copy of this message
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] } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 94.173.3.143 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php Edit -- https://master.php.net/note/edit/96678 Del: integrated -- https://master.php.net/note/delete/96678/integrated Del: useless -- https://master.php.net/note/delete/96678/useless Del: bad code -- https://master.php.net/note/delete/96678/bad+code Del: spam -- https://master.php.net/note/delete/96678/spam Del: non-english -- https://master.php.net/note/delete/96678/non-english Del: in docs -- https://master.php.net/note/delete/96678/in+docs Del: other reasons-- https://master.php.net/note/delete/96678 Reject -- https://master.php.net/note/reject/96678 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166897) next »