On the analysis of hook hooks in thinkphp

Source: Internet
Author: User

There is a hook class under the Library/think in the TP framework, which is used to instantiate classes and execute methods in the form of plug-ins.

static Private $tags = Array ();

Here is a static private member, here is the so-called hook function array, inside the specific content is an array

Array format: Arrays (' Method name ' =>array (class name, class name), ' method name ' =>array (class name))

Of course, in a single-instance design pattern, it is undoubtedly best to access these static members in a static way, so the get method of TP

It's a good illustration of the situation.

The following method of the Add plugin

This is the first to determine whether the method tag is first created, if it is a static zone array with a key value is the tag value, value is an empty array, and then compatible with the 2 write mode, one is the name array is a string form, is not intended to construct the above I said

That plug-in array

What's strange about this is that his EXE method doesn't do any of the class existence and method existence judgment here, it feels weird.

On the analysis of hook hooks in thinkphp

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.