Home > Backend Development > PHP Tutorial > 代码中的$form各表示什么

代码中的$form各表示什么

WBOY
Release: 2016-06-23 14:38:28
Original
1833 people have browsed it

下面这段代码中的$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;		}
Copy after login


回复讨论(解决方案)

后面是追加赋值 .=

这个函数最终的目的就是构造form这个变量的内容,内容是html的

$form这个就是一个变量,不要因为变量名叫form就疑惑了,另外后面的.=其实就是$form = $form + "..." 的意思

如果$form.='';
那么等价于$form.=$form+'';
我的疑惑是''好理解,但是$form又等价于啥呢

$form = "hello"; 
$form .= "world";
echo $form;
输出
hello world 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template