[Phpwm] Accessing class variable from sub function

Richard Harrison catchall at rjharrison.org
Wed Apr 16 12:28:26 BST 2008


Mike Tipping wrote:
> This is probably a silly question but I can't work it out.
>
> I'm using preg_replace_callback which takes a callback function as a
> parameter. The call to preg_replace_callback is within a class and I need
> the callback function to have access to the classes properties, but can't
> work out how to give it access.
>
> So with something like this:
>
> Class myclass {
>
>   public someData = array();
>   
>   function replaceText($someText) {
>     function callbackFunc($matches) {
>       print_r(xxx);
>     }    
>     reg_replace_callback('/{id="1"}/' ," callbackFunc", $fileContent);
>   }  
>
> }
>
> What do I need to replace xxx with to access the array someData?
>
> Or am I approaching this in completely the wrong way?
>
> Cheers
>
> Mike
>
>
>
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>
>   




More information about the Phpwm mailing list