Array_filter () of the callback function, PHP artifice.

Source: Internet
Author: User
Look at the project code yesterday, see a line of code is probably written like this
Array_filter ($array, Array ($this, ' functionname ');
Never seen this before, functionname is a method name for the controller. Curious how PHP works with this callback method? There is where you can learn this PHP artifice, I see the PHP manual does not have this kind of introduction ah.


Reply to discussion (solution)

Array array_filter (array input [, callback callback])

If callback is an object, the method should write an array (object name, method name)
But I did not read much, and did not see the statement of the authoritative document, do not remember how to know how to express the way

The manual has written:
An object's methods are passed as an array, the array's subscript 0 indicates the object name, and subscript 1 indicates the method name.
For static classes that are not instantiated as objects, to pass their methods, replace the object name indicated by the array 0 subscript with the name of the class.

  • 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.