【发布时间】:2013-01-14 22:33:25
【问题描述】:
我知道 echo 会回显内容并 return 将返回内容以供进一步处理。然而,我已经说过函数:
class Content{
protected $_html = '';
public function display_content(){
$this->_html = 'content';
}
public function __toString(){
return $this->html;
}
}
然后我有以下几点:
$content = new Content();
<p><?php $content->disaply_content(); ?></p>
我明白了:
<p></p>
content
作为页面的源代码。不管我是回显还是返回都没关系,无论哪种方式,它都会显示在标签的外面。
想法?
【问题讨论】:
-
显示页面时还有其他代码吗? 'content' 不应该出现在提供的代码中。