ARCHIVE: String concatenations
Last modified: January 13, 2009 - 20:55
The content on this page has been merged with the Coding Standards page.
Always use a space between the dot and the concatenated parts to improve readability.
<?php
$string = 'Foo' . $bar;
$string = $bar . 'foo';
$string = bar() . 'foo';
$string = 'foo' . 'bar';
?>When you concatenate simple variables, you can use double quotes and add the string inside, otherwise use single quotes.
<?php
$string = "Foo $bar";
?>When using the concatenating assignment operator ('.='), use a space on each side as with the assignment operator:
<?php
$string .= 'Foo';
$string .= $bar;
$string .= baz();
?>