#48556 [Opn]: eval() won't execute from __autoload()

From: Date: Mon, 15 Jun 2009 10:30:59 +0000
Subject: #48556 [Opn]: eval() won't execute from __autoload()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-138303@lists.php.net to get a copy of this message
ID: 48556 User updated by: neemah86 at gmail dot com Reported By: neemah86 at gmail dot com Status: Open Bug Type: SPL related Operating System: Debian Lenny (FreeBSD 7.0 also) PHP Version: 5.2.9 New Comment: class definition is: __autoload_failed($className, $message) Previous Comments: ------------------------------------------------------------------------ [2009-06-15 10:28:06] neemah86 at gmail dot com Description: ------------ Hi. Trying to throw exception from __autoload() by evaluating code (eval()). In earlier version of php5 that would give me exception that i need. Now it gives me fatal ignoring eval statement. Reproduce code: --------------- function __autoload_failed() { eval( 'if (!class_exists("ClassNotFoundException", false)) { ' .'final class ClassNotFoundException extends Exception {/*_*/} }' .'throw new ClassNotFoundException("'.$classname.': '.$message.'");' ); } function __autoload($className) { // insert your logic here __autoload_failed($className, 'not found'); // in any place, actually } Expected result: ---------------- ClassNotFoundException thrown Actual result: -------------- Fatal error ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48556&edit=1

« previous php.bugs (#138303) next »