【1】Indirect reference of variable:
<?php $a = 'b'; $$a = '123'; echo $b; ?>
The above output is 123
We can see that there is an extra $ in the second line of code, and the variable is accessed through the specified name. The specified name is stored in $a('b'), and the value of this variable $b is changed to 123. Therefore, such a variable of $b is created and assigned.
You can increase the number of references arbitrarily by adding an additional $ mark in front of the variable.
【2】Concatenate strings: Use the concatenation operator, that is, the period (.) in the English state, to concatenate the strings into a merged new string.
<?php $a = 'PHP5' ; $b = '功能强大' ; echo $a.$b; ?>
In order to let us understand the connection string better, we changed it based on the above example and turned it into something like this (PHP5: Powerful 2014)
In this example we see quotes, spaces and numbers added. Below we will use two methods to write, and you will find out the specific differences yourself:
<?php $c = $a.': '.$b.' 2014'; $c = $a.': '.$b.' '.2014; ?>
【3】Connection assignment operator: If you only connect one value to another value, you can use the connection assignment operator (.=). The following two statements are equivalent:
<?php $title = $title . $subtitle; $title .= $subtitle; ?>