|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2012-05-25 19:34 UTC] lcfsoft at gmail dot com
 Description: ------------ While OOP is conquering the world, "a function" is still sometimes enough. Introduce functionality for autoloading namespaces (of grouped functions, classes etc), in the same manner that exists for autoloading instantiated classes. (there is a similar feature request here https://bugs.php.net/bug.php? id=52385&edit=2, the key difference is that while autoloading for functions could get complicated, - for namespaces it is as straightforward as for classes) Test script: --------------- function __autoload($namespace) { require $namespace. '.php'; } //require_once 'myframework/mvc/dispatching.php'; // - want to get rid of these use myframework\mvc\dispatching; // - here it gets autoloaded even though it's not a class. dispatching\dispatch(...); PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 12:00:01 2025 UTC | 
I cannot imagine any "valid" use case for this. Autoloading is designated for classes only (that may happen to be located in a namespace). If you need autoloading functionality for group of functions, put them as static methods inside an abstract class. Example: -------- namespace MyFramework\MVC; abstract class Dispatching { static public function myFunc() { ... } // etc } -------- Then you can take advantage of the autoloading.