Re: Bind function parameters with create_function ('currying')

From: Date: Tue, 04 Sep 2007 18:05:58 +0000
Subject: Re: Bind function parameters with create_function ('currying')
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-261693@lists.php.net to get a copy of this message
I have a function which is my callback for preg_replace_callback - and it needs to be able to access a string and an object outside of itself. When I call create_function I can insert the string, but without serializing the object I can't figure out how to make it available to the function without making it global, which seems nasty. I've tried 'currying' the function - creating a new function out of it with the string and object parameters bound, but have the same problem - I can't get the object into the function. Can anyone point me towards a good solution? I guess I could also create a class with the one function, but that seems a wee bit messy to me.
It would be helpful if you could post a bare-bones example. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support

« previous php.general (#261693) next »