下面这段代码中的$form一会声明这个一会又赋值那个,实在是乱七八糟,不知这些在逻辑上怎么顺承的?
function __toString(){
$form='<form action="'.$this->action.'" method="post" >';
switch($this->shape){
case "rect":
$form.=$this->getRect();
break;
case "triangle":
$form.=$this->getTriangle();
break;
case "circle":
$form.=$this->getCircle();
break;
default:
$form.='请选择一个形状<br>';
}
$form.='<input type="submit" name="sub" value="计算">';
$form.='</form>';
return $form;
}
连字符
------解决方案--------------------
$form = "hello";
$form .= "world";
echo $form;
输出
hello world