The import method is an encapsulation implementation of the thinkphp framework for Class library imports, especially for import support for Project class libraries, extended class libraries, and Third-party class libraries, and earlier versions of the Import method can import directories and wildcard imports like Java import methods, and then consider performance issues. Improved and simplified in subsequent release updates, so the usage is straightforward. Call Format:
Import (' Class library name ', ' Start path ', ' Class library suffix ')
The Imprt method has an alias noun method that is specifically used to import a Third-party class library, except that the start path and class library suffix defaults are different.
Let's analyze the specific usage:
Import System base Class Library
The system base Class library actually refers to the Think Class library package, where the directory refers to the core Lib directory of the framework, and the import method can be used to import system base class libraries, for example:
Import (' Think.Util.Array ');
Represents the Lib/util/array.class.php class library file under the Import system directory, which is equivalent to the way we use
Require&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; Think_path ' lib/util/array.class.php ';
Multilevel catalogs can be supported, for example:
Import (' Think.Util.U1.ClassA '); Import (' Think.Util.U1.A2.ClassB ');
After you import the class library through the import method, you can instantiate the class library.
Import an extended class library
The Extended class library is located under the Extend/library directory, which is the system's public extended class library directory, and currently supports only Org and COM packages for the Extended class library package.
Import (' ORG. Util.image '); Import (' Com.Sina.OAuth ');
Will import the third party class libraries (extend/library/org/util/image.class.php and extend/library/com/sina/oauth.class.php class library files, respectively) below the extended directory. The third party Class library package can only support org and COM two, and the following subdirectories are optionally added.
Import Project Application Class Library
If you do not specify a start import path, the class library package think, ORG, COM is considered an import Project Application class library, for example:
Import ("MyApp.Action.UserAction"); Import ("MyApp.Model.InfoModel");
Represents the Useraction and Infomodel class library files that import MyApp projects, since we are typically importing the class libraries below the current project, so we can write a simple:
Import (@. Action.useraction "); Import ("@.model.infomodel");
The @ symbol indicates that the class library under the current project is imported, which in turn facilitates code porting of the Project class library, and does not need to be changed if the project name changes or moves below the other item.