note 48099 added to language.oop5.autoload

From: Date: Sat, 11 Dec 2004 17:14:51 +0000
Subject: note 48099 added to language.oop5.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-81696@lists.php.net to get a copy of this message
The following might provide a good work-around for throwing exceptions from the __autoload function when a file containing the correct class doesn't exists. function __autoload ($class_name) { $file = 'system/objects/' . $class_name . '.inc.php'; if (!file_exists ($file)) { return eval ("class $class_name {" . " function $class_name () {" . " throw new Exception ();" . " }" . "}"); } require_once ($file); } Cheers, Nolan ---- Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48099 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48099&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48099&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48099&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48099&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48099&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48099&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48099&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81696) next »