In formal language theory (and therefore in programming languages), concatenation is the operation of joining two character strings end to end. For example, the strings "foo" and "bar" may be concatenated to give "foobar". In programming languages, string concatenation is usually accomplished by putting a concatenation operator between two strings (operands). The following statement assumes the language uses the "+" symbol as its concatenation operator:
print "Hello " + "World";
This code will print to the screen:
Hello World
Some languages require the user call a function to concatenate a string of characters.
my $stringVar;
$stringVar = "World";
print "Hello " . $stringVar;
one could type:
my $stringVar;
$stringVar = "World";
print "Hello $stringVar";
$stringVar gets interpolated in the rest of the string. The Perl interpreter prints Hello World instead of Hello $stringVar because a) the double quotes around the string indicate to the interpreter that it should be parsed for variables and character escapes, and b) it recognizes that $stringVar is a variable. It can do this because all scalar variables in Perl (and all variables in PHP) must begin with the "$" token whereas most languages don't usually require variables to have special characters.
Конкатенация | Konkatenation (Listen) | Concaténation | Konkatenacja | Concatenation | 串接
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Concatenation".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world