SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict chiefmonkey's Avatar
    Join Date
    Aug 2002
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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);
        } 
    I also tried
    PHP Code:
      execute() {
        
    preg_replace_callback("/\?/"" \$this->parse"$statement);
        } 
    Didn't work, looked about a bit and found PHP5 related code.

    So I then tried making the function static and
    PHP Code:
       execute() {
         
    preg_replace_callback("/\?/", array(__CLASS__'parse'), $statement);
         } 
    still didn't work so I tried

    PHP Code:
       execute() {
         
    preg_replace_callback("/\?/", array(self,'parse'), $statement);
         } 
    Still no luck.
    Any suggestions
    George
    Got Sig!

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •