在閱讀一本關於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