note 55083 deleted from language.oop5.autoload by felipe

From: Date: Mon, 24 Mar 2008 22:32:25 +0000
Subject: note 55083 deleted from language.oop5.autoload by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137490@lists.php.net to get a copy of this message
Note Submitter: sr at brightlight dot ch ---- 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 ::.

« previous php.notes (#137490) next »