method as callback function
Posted: Thu Apr 13, 2006 5:52 pm
Hello, I want to ask you to help me with this problem:
I want to a callback function for preg_replace_callback. This callback is a class method because it need an access to some object variables.
I've found this solution how to "adress" it:
preg_replace_callback($pattern, array($this,'my_callback'),$string);
works great, but..
I change the instantion (is my english correct???) variable in my_callback:
$this->inst_var++;
while printing some debug info in my_callback, $this->inst_var changes for every pattern convenient in preg_replace_callback.
The problem is, that when i "echo" $this->inst_var after finishing preg_replace_callback, "0" is printed..
Before trying to implement THE SAME in "objects", everything was working good..
I'll be very greatful for any help
Thanks
HoHo
I want to a callback function for preg_replace_callback. This callback is a class method because it need an access to some object variables.
I've found this solution how to "adress" it:
preg_replace_callback($pattern, array($this,'my_callback'),$string);
works great, but..
I change the instantion (is my english correct???) variable in my_callback:
$this->inst_var++;
while printing some debug info in my_callback, $this->inst_var changes for every pattern convenient in preg_replace_callback.
The problem is, that when i "echo" $this->inst_var after finishing preg_replace_callback, "0" is printed..
Before trying to implement THE SAME in "objects", everything was working good..
I'll be very greatful for any help
Thanks
HoHo