#20481 [Bgs->Opn]: preg_replace_callback() incorrect documentation

From: Date: Mon, 24 May 2004 17:26:05 +0000
Subject: #20481 [Bgs->Opn]: preg_replace_callback() incorrect documentation
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969360899@lists.php.net to get a copy of this message
ID: 20481 User updated by: bikeman82 at hotmail dot com Reported By: bikeman82 at hotmail dot com -Status: Bogus +Status: Open Bug Type: Documentation problem Operating System: All PHP Version: 4.2.3 New Comment: 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 ... Previous Comments: ------------------------------------------------------------------------ [2004-05-22 11:09:48] nlopess@php.net I think that the docs are clear enough. ------------------------------------------------------------------------ [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

« previous php.doc (#969360899) next »