note 108169 added to function.autoload

From: Date: Wed, 04 Apr 2012 13:42:54 +0000
Subject: note 108169 added to function.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-186959@lists.php.net to get a copy of this message
__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!"; } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 222.127.34.100 ---- Manual Page -- http://www.php.net/manual/en/function.autoload.php Edit -- https://master.php.net/note/edit/108169 Del: integrated -- https://master.php.net/note/delete/108169/integrated Del: useless -- https://master.php.net/note/delete/108169/useless Del: bad code -- https://master.php.net/note/delete/108169/bad+code Del: spam -- https://master.php.net/note/delete/108169/spam Del: non-english -- https://master.php.net/note/delete/108169/non-english Del: in docs -- https://master.php.net/note/delete/108169/in+docs Del: other reasons-- https://master.php.net/note/delete/108169 Reject -- https://master.php.net/note/reject/108169 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186959) next »