1 2 3 4 5 6 7 8 9 a |
<?php function AutoLoad ($className) {$className = LTrim ($className, ' \ '); $fileName = '; $namespace = '; if ($lastNsPos = Strripos ($className, ')) {$namespace = substr ($className, 0, $lastNsPos); $className = substr ($className, $lastNsPos + 1); $fileName = str_replace (' \ ', Directory_separator, $namespace). Directory_separator; $fileName. = Str_replace (' _ ', Directory_separator, $className). '. php '; Require $fileName; } |
Mandatory conventions
A qualified name space-class should follow such a structure <vendor name> (<Namespace>) *<class name>
A fully-qualified namespace and class must have the following structure <vendor name> (<Namespace>) *<class N Ame>
Each name space needs to have a top-level namespace ("Vendor name") (provider name).
Each namespace must have a top-level namespace ("Vendor Name").
Each name space can have any number of child namespaces
Each namespace can have as many sub-namespaces as it wishes.
Each namespace separator is converted to a path separator when it is loaded from the file system
Each namespace separator are converted to a directory_separator when loading from the file system.
Each underscore (_) in the class name is converted to a path separator, and the underscore character (_) in the namespace has no specific meaning
Each _ character in the CLASS NAME was converted to a directory_separator. The _ character has no special meaning in the namespace.
A qualified namespace-the file to be loaded by the class must be the end of. PHP
The Fully-qualified namespace and class are suffixed with. php as loading from the file system.
Vendor name (provider name), namespace, the character in the class name can be any combination of case
Alphabetic characters in vendor names, namespaces, with class names May is of any combination of the case and lower.