Phpautoload PSR-0 Standard

Source: Internet
Author: User
Tags file system
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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.