note 108169 deleted from function.autoload by googleguy

From: Date: Sat, 19 Jan 2013 03:47:41 +0000
Subject: note 108169 deleted from function.autoload by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193251@lists.php.net to get a copy of this message
Note Submitter: carloagonzales at gmail dot com ---- __autoload magic function can also be used inside a class and have the class handle the inclusion of class files. /******** index.php ********/ <?php class foobar { public function executeMe(){ function __autoload($classname){ include $classname . '.php'; } } } $foo = new foobar(); $foo->executeMe(); some::foobar2(); //will output "hello! I'm static!" $bar = new some(); $bar->foobar(); //will output "hello! I'm public!" ?> /******** some.php ********/ <?php class some { public function foobar (){ echo "hello! I'm public!"; } static function foobar2 (){ echo "hello! I'm static!"; } } ?>

« previous php.notes (#193251) next »