在阅读一本关于 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)”?
有什么解释吗?