note 95456 added to function.spl-autoload-register
| From: | rayro at gmx dot de | Date: | Mon, 04 Jan 2010 11:14:51 +0000 |
| Subject: | note 95456 added to function.spl-autoload-register | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164590@lists.php.net to get a copy of this message | ||
It is never a good idea and a unconscienable concept to create the classes in the autoload function
via eval.
It should be a nice feature with these Exception, but i think anyone is able to handle it without
this method although. Atm i dont realize for what this is good for...
As i might note, class_exists() will ever define the classes u only want to check for existance, and
will therefor ever return true:
<?php
function EvalIsEvil($class) {
eval('class '.$className.'{}');
}
spl_autoload_register('EvalIsEvil');
if (class_exists($s="IsMyModuleHere")) {
// this is no module, but get there with eval()...
return new $s();
}
?>
----
Server IP: 212.124.37.9
Probable Submitter: 85.8.70.161
----
Manual Page -- http://www.php.net/manual/en/function.spl-autoload-register.php
Edit -- https://master.php.net/note/edit/95456
Del: integrated -- https://master.php.net/note/delete/95456/integrated
Del: useless -- https://master.php.net/note/delete/95456/useless
Del: bad code -- https://master.php.net/note/delete/95456/bad+code
Del: spam -- https://master.php.net/note/delete/95456/spam
Del: non-english -- https://master.php.net/note/delete/95456/non-english
Del: in docs -- https://master.php.net/note/delete/95456/in+docs
Del: other reasons-- https://master.php.net/note/delete/95456
Reject -- https://master.php.net/note/reject/95456
Search -- https://master.php.net/manage/user-notes.php