Thinkphp313 use namespace note

Source: Internet
Author: User
: This article mainly introduces Thinkphp313 using namespace. if you are interested in the PHP Tutorial, refer to it. After using JAVA for many years, our company now uses thinkphp. if namespace is not introduced, it is very uncomfortable. when there are many classes, it is easy to define duplicate names.

So start using namespace. some notes.

When using namespace:

1. call class: Call the namespace class. after import () is used, the full path of namespace must be used during instantiation. For example:

Import ('@. UNI. vendor. disngding. dingservice'); class DingAction extends Action {$ dtSvr = new \ vendor \ disngding \ DingService (); $ rsc}

2. the class defined by namespace. the class without namespace is called.

All the classes from import will be under the \ root directory. Therefore, add \

Namespace vendor \ dingding; import ('@. UAI. dal. DSysUser'); class corpUserService {public static function getUserCorpIdAndAgentIdByUsername ($ username) {$ userSvr = new \ DSysUser ();}

3. classes not introduced. in the classes defined by namespace, all classes must be rooted. for example, Model () must be written as \ Model ();

The preceding section describes Thinkphp313's usage of namespace, including the Thinkphp313 notes. if you are interested in the PHP Tutorial.

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.