note 74026 deleted from language.oop5.autoload by cmb

From: Date: Sun, 26 May 2019 09:11:22 +0000
Subject: note 74026 deleted from language.oop5.autoload by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211132@lists.php.net to get a copy of this message
Note Submitter: Andrea Giammarchi ---- Another workaround for Exception problem (Klaus Schneider style) <?php define('CLASS_DIR', 'php/classes/'); function __autoload($name) { if($exists = !class_exists($name) && file_exists($class = CLASS_DIR.$name.'.class.php')) require $class; elseif(!$exists) { eval('class '.$name.' extends Exception {}'); throw new $name('[__autoload] this file doesn\'t exists: '.$class); } } try { new Undefined; } catch(Undefined $e) { echo $e->getMessage(); } // You should use generic Exception too catch(Exception $e) { echo $e->getMessage(); } ?>

« previous php.notes (#211132) next »