How does preg_replace_callback call back an instance method?

Source: Internet
Author: User
{Code...} $ callback of this function, which can be called by passing in a string, static method or something. How can we specify an instance method?
Mixed preg_replace_callback (mixed $ pattern, callable $ callback, mixed $ subject [, int $ limit =-1 [, int & $ count])

$ Callback of this function, which can be called after a string is passed in, static method or something. How can we specify an instance method?

Reply content:
Mixed preg_replace_callback (mixed $ pattern, callable $ callback, mixed $ subject [, int $ limit =-1 [, int & $ count])

$ Callback of this function, which can be called after a string is passed in, static method or something. How can we specify an instance method?

It's all right. Just use an array for passing.

Class A {public function test ($ matches) {}}$ a = new A (); preg_replace_callback ("/(w +)/", array ($, 'test'), 'asfdasdf asdfsad ');

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.