Concatenation in PHP produces ‘0’ (zero)

If you’re concatenating a string in PHP and the result is a zero (“0”), check you haven’t mixed up your languages and used a “+” instead of “.” as your concatenation operator.

As a regular developer in C# and JavaScript regular, I sometimes write “$result = $part1 + $part2″ whereas I should write “$result = $part1 . $part2″.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>