Class auto-loader
| From: | Stanislav Malyshev | Date: | Sat, 24 Jun 2000 18:05:08 +0000 |
| Subject: | Class auto-loader | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-22237@lists.php.net to get a copy of this message | ||
Here on the list someone brought the idea of auto-loading classes on
demand. Attached is the patch that allows to do this. Please comment on
it. If you like the idea, I'll extend it (as to providing convenient
standard auto-loader, probably entering auto-loader into configure,
hooking it to various places like sessions, etc.) to be fully usable.
Example usage:
function load($class) {
var_dump($class);
if($class == "foo") {
include("foo.inc");
return true;
}
return false;
}
set_class_loader("load");
$x = new foo;
?>
In foo.inc:
<?
class foo {
function wow() { echo "wow!"; }
}
?>
--
Stanislav Malyshev stas@zend.com
+972-3-6139665