note 55083 added to language.oop5.autoload

From: Date: Mon, 25 Jul 2005 09:52:50 +0000
Subject: note 55083 added to language.oop5.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-92406@lists.php.net to get a copy of this message
If you want to autoload functions you can do this with a little work-around: <?php class utilities { protected static $instance; protected function __construct() { } public function get() { if (isset(self::$instance)) { return self::$instance; } else { self::$instance = new utilities(); return self::$instance; } } public function __call($function, $arguments) { if (!function_exists($function)) { include_once("function.$function.inc"); } return call_user_func_array($function, $arguments); } } utilities::get()->someFunction(...); // the file 'function.someFunction.inc' should be somewhere in the include_path ?> Unfortunately __call() is only invoked when the method is accessed via -> and not via ::. ---- Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55083 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55083&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55083&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55083&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55083&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55083&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55083&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55083&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92406) next »