String concatenations

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();
?>

 
 

Drupal is a registered trademark of Dries Buytaert.