I am having some trouble with replacing preg_replace with /e modifier to preg_replace_callback in this function:
private function parseFunctions() {
// replaces includes ( {include file="..."} )
while( preg_match( "/" .$this->leftDelimiterF ."include file=\"(.*)\.(.*)\""
.$this->rightDelimiterF ."/isUe", $this->template) )
{
$this->template = preg_replace( "/" .$this->leftDelimiterF ."include file=\"(.*)\.(.*)\""
.$this->rightDelimiterF."/isUe",
"file_get_contents(\$this->templateDir.'\\1'.'.'.'\\2')",
$this->template );
}
// deletes comments from the template files
$this->template = preg_replace( "/" .$this->leftDelimiterC ."(.*)" .$this->rightDelimiterC ."/isUe",
"", $this->template );
}
Can you help me with this?
EDIT:
I managed to fix the second one, but the other
{
$this->template = preg_replace_callback( "/" .$this->leftDelimiterF ."include file=\"(.*)\.(.*)\""
.$this->rightDelimiterF."/isU",
function(){$replacement="file_get_contents(\$this->templateDir.'\\1'.'.'.'\\2')";
return $replacement;},
$this->template );
}
did not work. I got following error message:
file_get_contents($this->templateDir.'\1'.'.'.'\2') file_get_contents($this->templateDir.'\1'.'.'.'\2') file_get_contents($this->templateDir.'\1'.'.'.'\2') file_get_contents($this->templateDir.'\1'.'.'.'\2') file_get_contents($this->templateDir.'\1'.'.'.'\2') file_get_contents($this->templateDir.'\1'.'.'.'\2')
I am still relatively new to php so i am not sure how to handle this issue.