For example, the following expression uses the "+" symbol as the concatenation operator:
print "Hello " + "World";
Different languages use different operators. Most languages use the plus sign ("+") though several deviate from this norm.
| Operator | Symbol name | Language |
|---|---|---|
| + | plus sign | ActionScript, BASIC, C++, C#, Java, JavaScript, Pascal, Python, Ruby, Windows PowerShell, SQL, GML |
| & | ampersand | Ada, AppleScript, VHDL, Visual Basic |
| . | dot | Perl (before version 6), PHP |
| ~ | tilde | Perl 6 |
| // | double slash | Fortran |
| || | double vertical bar | REXX, SQL, Icon |
| $+ | dollar plus | mIRC Scripting Language |
For a more detailed comparison, please see the concatenation comparison article.
For example, in PHP and Perl:
//Example 2 (combined assignment and concatenation ".=")
$var = "Hello ";
$var .= "World";
Both examples produce the same result.
For example, in Perl, the concatenation syntax:
can be substituted with the string literal syntax:
since double quoted string literals in Perl indicate scalar variables with the dollar sign ($) scalar sigil.