preg_replace_callback(): Requires argument 2 to be a valid callback

后端 未结 1 1285
礼貌的吻别
礼貌的吻别 2021-01-26 07:58

I\'m learning PHP with some pre-made websites so I can see how it\'s done because I\'m a visual learner, but I\'ve run into a problem.

I got an error saying

相关标签:
1条回答
  • 2021-01-26 08:17

    The PHP documentation describes this function as

    Perform a regular expression search and replace using a callback:

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

    The callable class requires the name of a function (as a string, e.g. 'print_r') or an actual function function(){ // do something }.

    The preg_replace_callback() process will pass an array of matches into the "callable function" and return a string. From the docs, describing the second parameter:

    A callback that will be called and passed an array of matched elements in the subject string. The callback should return the replacement string. This is the callback signature:

    string handler ( array $matches )
    0 讨论(0)
提交回复
热议问题