php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #20481 preg_replace_callback() incorrect documentation
Submitted: 2002-11-18 08:21 UTC Modified: 2004-05-25 15:51 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: bikeman82 at hotmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.2.3 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bikeman82 at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-11-18 08:21 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-22 11:09 UTC] nlopess@php.net
I think that the docs are clear enough.
 [2004-05-24 19:26 UTC] bikeman82 at hotmail dot com
They are clear, yes, but incorrect, as I stated in my comments below.  It's up to you to leave this like this or not, I did my duty by telling you this ...

And also, I don't know exactly what was wrong, as you can see, the original bug submission was done close to one year and a half ago ...
 [2004-05-25 15:51 UTC] nlopess@php.net
Thanks for your bug report!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 12:01:31 2024 UTC