在阅读一本关于php的书时,我在一段代码中找到了一条逻辑上对我没有意义的代码。代码行是一类功能的一部分:php变量分配混淆
private function replaceTags($pp = false) {
//get the tags in the page
if($pp == false) {
$tags = $this->page->getTags();
} else {
$tags = $this->page->getPPTags();
}
//go through them all
foreach($tags as $tag => $data) {
//if the tag is an array, then we need to do more than a simple find and replace!
if(is_array($data)) {
if($data[0] == 'SQL') {
//it is a cached query...replace tags from the database
$this->replaceDBTags($tag, $data[1]);
} elseif($data[0] == 'DATA') {
//it is some cahched data...replace tags from cached data
$this->replaceTags($tag, $data[1]);
}
} else {
//replace the content
$newContent = str_replace('{' . $tag . '}', $data, $this->page->setContent($newContent));
$this->page->setContent($newContent);
}
}
}
这没有意义,我的具体线路是:
$newContent = str_replace('{' . $tag . '}', $data, $this->page->setContent($newContent));
你如何传递变量“$ newContent”到“ setContent($ newContent)“何时还没有值?
任何解释?
正在生成的内容在哪里? – Orangepill