#20481 [Com]: preg_replace_callback() incorrect documentation
| From: | online131 at hotmail dot com | Date: | Thu, 30 Oct 2003 03:19:32 +0000 |
| Subject: | #20481 [Com]: preg_replace_callback() incorrect documentation | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969356770@lists.php.net to get a copy of this message | ||
ID: 20481
Comment by: online131 at hotmail dot com
Reported By: bikeman82 at hotmail dot com
Status: Assigned
Bug Type: Documentation problem
Operating System: All
PHP Version: 4.2.3
Assigned To: k.schroeder
New Comment:
Yep, this is the time to fix the documentation, so that new users like
me will not be confused too!
Previous Comments:
------------------------------------------------------------------------
[2002-11-18 08:21:06] bikeman82 at hotmail dot com
The documentation of preg_replace_callback() states that it is
functioning exactly like preg_replace(), except for the second
argument, that should be a 'callback'.
This is the current text:
"The behavior of this function is almost identical to preg_replace(),
except for the fact that instead of replacement parameter, one should
specify 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 function was added in PHP 4.0.5."
I think this is way too vague, and most of all, incorrect. Though the
functionality is similar, it is not 'almost identical'. First of all,
the callback-variant of this function is (in my release, 4.2.3) not
capable of detecting multiple patterns and passing them to multiple
callback-functions. Secondly, there is the item that is discussed in
the (English) user comments in the online version of this function,
namely that when you try to call a member function of a class from
within that class, you have to pass it an Array with as first element a
reference to $this, and then, secondly the callback-function.
Actually, I am not a very experienced php-user, and normally, I would
not post this bug, but somebody in the php.doc-newsgroup encouraged me
to do so, so this is it ...
I hope I can help the huge community I try to become a member, gets a
little improved by my first cotribution to it ...
Greetz,
Bikeman
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20481&edit=1