thinkphp methods for importing external classes

Source: Internet
Author: User
Tags zend

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

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.