Home > Backend Development > PHP Tutorial > PHP learning code miscellaneous notes, PHP code miscellaneous notes_PHP tutorial

PHP learning code miscellaneous notes, PHP code miscellaneous notes_PHP tutorial

WBOY
Release: 2016-07-12 08:58:49
Original
758 people have browsed it

php learning code miscellaneous notes, php code miscellaneous notes

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>
Copy after login

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>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1101615.htmlTechArticlephp learning code miscellaneous notes, php code miscellaneous notes 16/2/22 String connection (1) connection operator (. ): It returns the string resulting from appending the right argument to the left argument. (2) Connection assignment operation...
Related labels:
php
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