PHP – Concatenate Strings

String concatenation means combining two or more strings into one. In PHP, you can achieve this with the . operator.

Tutorials dojo strip

Example 1: Basic Concatenation

You can combine two strings like this:

PHP

The output will be YamahaR1, without any space between the words.

Example 2: Adding a Space

To add a space between the concatenated strings, you can include a space character:

PHP

The output will now be Yamaha R1.

Example 3: Using Double Quotes

A more straightforward way to concatenate strings with spaces is by using double quotes:

PHP

By enclosing both variables in double quotes and placing a space between them, the output will also be Yamaha R1.

Tutorials dojo strip