[Phpwm] Passing parameters to callback functions

Greg Jones greg.jones at gmail.com
Mon May 19 10:24:28 BST 2008


You could use one of the methods for partial-application here:
http://www.sitepoint.com/blogs/2007/12/15/the-state-of-functional-programming-in-php/
or here: http://metapundit.net/sections/blog/166 but they're quite
messy. Or perhaps just with a create_function() along the lines, which
is still quite messy:

$callback = create_function('$matches', "return
replaceContent(\$matches,$year,$month);");

($matches is escaped as it wants to be interpreted by create_function,
the $year and $month are your pre-defined variables). You should be
able to expand that to handle it being a class-method, but I'm not
sure how $this works inside the create_function scope...)

Greg



More information about the Phpwm mailing list