У меня возникли некоторые проблемы с заменой preg_replace с/е модификатора preg_replace_callback в этой функции:Проблемы с заменой/модификатором е к preg_replace_callback
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);
}
Можете ли вы помочь мне с этим?
EDIT:
мне удалось зафиксировать второй, а другой
{
$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);
}
не работает. я получил следующее сообщение об ошибке:
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 Я все еще относительно новичок в php, поэтому я не уверен, как справиться с этой проблемой.
Я не понимаю, что вы делаете, почему вы заменить в то время, а затем внутри самого цикла. Просто одного из них должно быть достаточно. –
Я тоже не уверен. Я не писал его изначально, мне нужно только иметь дело с ним. –
Так вы могли бы хотя бы дать лучшее объяснение проблемы? –