Afficher un message
Vieux 18/06/2008, 23h07   #1
Jeff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
 
Page generated in 0,05603 seconds with 9 queries