变量已经在方法中定义但执行的时候还报错?
Notice: Undefined variable: link_start in D:\wamp\www\mysqli\comment.class.php on line 70这个变量已经定义在这个方法里面了,但是那个首页还是报错?
这下面是comment.class.php中的代码
public function output(){
if($this->data['url']){
$link_start="<a href='".$this->data['url']."' target='_blank'>";
$link_end="</a>";
}
$dateStr=date("Y年m月d日 H:i:s",$this->data['pubTime']);
$res=<<<EOF
<div class='comment'>
<div class='face'>
{$link_start}
<img width='50' height='50' src="img/{$this->data['face']}.jpg" alt="" />
{$link_end}
</div>
<div class='username'>
{$link_start}
{$this->data['username']}
{$link_end}
</div>
<div class='date' title='发布于{$dateStr}'>
{$dateStr}
</div>
<p>{$this->data['content']}</p>
</div>
EOF;
return $res;
}
70行的代码是<div class='face'>下的{link_start}这里,其他地方的link_start, link_end 也报错,请问这是什么 原因?