16/2/22
String concatenation
(1) Concatenation operator ("."): It returns the string obtained by appending the right parameter to the left parameter.
(2) Connection assignment operator (".="): It appends the right parameter to the left parameter.
Equivalent to = in JS.
<span>$b</span> = "东边日出西边雨"<span>; </span><span>$b</span> .= ",道是无晴却有晴"<span>; </span><span>$c</span> = "东边日出西边雨"<span>; </span><span>$c</span> = <span>$c</span>.",道是无晴却有晴"<span>; </span><span>echo</span> <span>$b</span>."<br />";<span>//</span><span>东边日出西边雨,道是无晴却有晴</span> <span>echo</span> <span>$c</span>."<br />";<span>//</span><span>东边日出西边雨,道是无晴却有晴</span>
Assignment operation
$a = "cmflovehxc";
$b=$a;
$c=&$a;
$a = "hxclovecmf";
echo $b."
";
echo $c;
(1) "=": Assign the value of the expression on the right to the operand on the left. It copies the value of the expression on the right and gives it to the operand on the left. In other words, a memory is allocated for the operand on the left first, and then the copied value is placed in this memory.
Equivalent to the equal sign in JS. Variable assignment; two variables are two different heap memories.
(2) "=&": reference assignment, which means that both variables point to the same data. It will cause two variables to share a piece of memory. If the data stored in this memory changes, the values of both variables will change.
Two variables are two identical heap memories.
Constant
<span> 1</span> <span>define</span>("PI1",3.14<span>); </span><span> 2</span> <span>$p</span> = "PI1"<span>; </span><span> 3</span> <span>echo</span> <span>$p</span>;<span>//</span><span>PI1</span> <span> 4</span> <span>echo</span> <span>constant</span>(<span>$p</span>);<span>//</span><span>3.14</span> <span> 5</span> <span>if</span>(<span>defined</span>(<span>$p</span>)==<span>true</span><span>){ </span><span> 6</span> <span>echo</span> '111'<span> ; </span><span> 7</span> }<span>else</span><span>{ </span><span> 8</span> <span>echo</span> '222'<span>; </span><span> 9</span> <span>} </span><span>10</span> <span>//</span><span>返回111<br />11 //constant()与defined()都有一种翻译功能<br /></span>