+ 2

What is concatenation in php?Please answer the question if you know the answer.

27th Mar 2018, 8:06 PM
Anurag Mahadik
Anurag Mahadik - avatar
4 Antworten
+ 4
Concatenation is the process of appending one string with another, which can be achieved with the dot operator in PHP, like this: $text = "Hello "; $text2 = "world!"; $text .= $text2; echo $text; The output is hello world.
27th Mar 2018, 8:32 PM
Kevin Eldurson
Kevin Eldurson - avatar
+ 15
i am not sure for php but in most programming languages concatenation means to concate two string like : "string1" + "string2" so result string is: "string1string2"
27th Mar 2018, 8:20 PM
Vukan
Vukan - avatar
+ 3
Vukan, if you use the + operator with a string you will get unexpected behavior. PHP will convert the string to a number and try to add it. If not possible, it will return 0.
27th Mar 2018, 11:04 PM
Mickel
Mickel - avatar
+ 1
It's the dot (.) that makes the concatenation in PHP. It's part of the so called string operators. Examp#See below: $firstName = 'John'; $lastName = 'Doe'; $fullName = $firstName . ' ' . $lastName; echo $fullName; It outputs "John Doe", with space in between them.
27th Mar 2018, 8:35 PM
Denis Marinov
Denis Marinov - avatar