return function in class
I had this little bit of code:
function parseTemplateData($file){
$file2=preg_replace_callback(
"/<edit(.*?)>/s",
"parseEditTag",
$file);
echo $file2;
}
and that did what I needed, so I thought I'll put it in a class:
class FOO{
public function parseTemplateData($file){
$file2=preg_replace_callback(
"/<edit(.*?)>/s",
"parseEditTag",
$file);
echo $file2;
}
public function parseEditTag($tag_content){
....
}
It is, of course looking for parseEditTag *outside* the class. So, I
thought:
$file2=preg_replace_callback(
"/<edit(.*?)>/s",
"$this->parseEditTag",
$file);
Which failed.
Then I thought:
$file2=preg_replace_callback(
"/<edit(.*?)>/s",
EDIT_PAGE::parseEditTag(),
$file);
Now that calls the function, but doesn't pass in the match.
So I thought I'd try to use create_function. But even if I could
figure out how to pass in the matches, I still can't get it to call the
method in the class.
So, I'm thinking there must be another plan. Or another beer.
Maybe I'm just thinking too perl!
Jeff
|