note 77471 deleted from language.oop5.autoload by cmb

From: Date: Sun, 26 May 2019 09:10:34 +0000
Subject: note 77471 deleted from language.oop5.autoload by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211130@lists.php.net to get a copy of this message
Note Submitter: rlee0001 at sbcglobal dot net ---- If you would like __autoload to throw an exception when the class cannot be loaded instead of causing a fatal error, consider this: <?php function __autoload ($className) { $fileName = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $status = (@include_once $fileName); if ($status === false) { eval(sprintf('class %s {func' . 'tion __construct(){throw new Project_Exception_AutoLoad("%s");}}', $className, $className)); } } $pageController = 'Project_My_Class'; // "Project/My/Class.php" try { $obj = new $pageController(); } catch (Project_Exception_AutoLoad $e) { header('HTTP/1.0 404 Not Found'); printf('<h1>Not Found</h1><p>The requested page %s was not found on this server.</p><hr /><em>$id$</em>', $_SERVER['REQUEST_URI']); } ?>

« previous php.notes (#211130) next »