SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Sep 28, 2005, 15:26 #1
Slightly OT: preg_replace_callback in a class
Ok I have been struggling with this for the last hour. I have looked around a bit, and have found some 'answers' on the internals mailing list and a few other forums.
I am running PHP 5.0.4
I want to use preg_replace_callback within a class. I have 2 methods, execute(), which calles preg_replace_callback and parse() which is called back.
so I tried
PHP Code:
execute() {
preg_replace_callback("/\?/", array(&$this,'parse'), $statement);
}
PHP Code:execute() {
preg_replace_callback("/\?/", " \$this->parse", $statement);
}
So I then tried making the function static and
PHP Code:execute() {
preg_replace_callback("/\?/", array(__CLASS__, 'parse'), $statement);
}
PHP Code:execute() {
preg_replace_callback("/\?/", array(self,'parse'), $statement);
}
Any suggestions
GeorgeGot Sig!
-
Sep 28, 2005, 15:48 #2
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Doesn't this work ?
PHP Code:execute() {
preg_replace_callback("/\?/", array($this, 'parse'), $statement);
}
Bookmarks