How to implement callback methods inside classes (PHP)

Posted by sombe on Stack Overflow See other posts from Stack Overflow or by sombe
Published on 2010-04-06T11:19:27Z Indexed on 2010/04/06 11:33 UTC
Read the original article Hit count: 217

Filed under:
|
|
|
|

I need to use a class callback method on an array inside another method (the callback function belongs to the class).

class Database {

      public function escape_string_for_db($string){
             return mysql_real_escape_string($string);
      }

      public function escape_all_array($array){
             return array_filter($array,"$this->escape_string_for_db");
      }
}

Is this the right way to go about that? (I mean, in terms of the second parameter passed to array_filter)

© Stack Overflow or respective owner

Related posts about php

Related posts about array