34,333
edits
Changes
→PHP String Concatenation Operator
<tt>My favorite color is Green.</tt>
== Concatenation of Numbers and Strings in PHP ==
We mentioned at the begining of this section that it is also possible to mix numbers and strings in a concatenation operation to create strings. For example we can include the number 6 in our string as follows:
<pre>
echo 6 . ' is my lucky number';
</pre>
The above example will create output as follows:
<tt>6 is my lucky number</tt>
We can also performa calculation and have the result included in the concatenation:
<pre>
echo 6 + 5 . ' is my lucky number'
</pre>
In this example the mathematical operation will be evaluated before the concatenation to produce:
<tt>11 is my lucky number</tt>