Believe that a lot of people in the use of TP when the use of external classes of various unsuccessful
Here is a detailed introduction of the following methods and attention to detail
To manually load a third-party class library
Because the third-class library does not have a specific namespace, there are several ways to manually import the
1.import method can import any class library
① Importing the Org Class Library package
import("Org.Util.Date");
② importing the class below the home module
import("Home.Util.UserUtil");
③ import the class below the current module
import("@.Util.Array");
④ Importing Vendor Class Library packages
import(‘Vendor.Zend.Server‘);
Note the correctness of the path. After the successful introduction of these classes, be sure to instantiate the classes before calling them.
2. Importing external classes using vendor
Note: Under UNIX or Linux hosts are case-sensitive, so when using the import method, you should pay attention to the case of the directory name and the class library name, otherwise the import will fail.
Vendor(‘Zend.Filter.Dir‘);
Detailed participation in the Official Handbook: http://document.thinkphp.cn/manual_3_2.html#autoload;
thinkphp methods for importing external classes