Concept
How do you concatenate strings in PHP?
ComputerScienceOne / String Functions
"PHP has a concatenation operator built into the language. To concatenate one or more strings together, you can use a simple period between them as the concatenation operator. Concatenation results in a new string.\n\n1 $firstName = \"Tom\";\n\n2 $lastName = \"Waits\";\n\n3\n\n4 $formattedName = $lastName . \", \" . $firstName;\n\n5 //formattedName now contains \"Waits, Tom\"\n\nConcatenation also works with other variable types.\n\n1 $x = 10;\n\n2 $y = 3.14;\n\n3\n\n4 $s = \"Hello, x is \" . $x . \" and y = \" . $y;\n\n5 //s contains \"Hello, x is 10 and y = 3.14\""
Related Ideas
- How can strings be concatenated in PHP?ComputerScienceOne · String Concatenation
- How does PHP support basic input and output?ComputerScienceOne · String Concatenation
- How can you add or remove characters from a PHP string?ComputerScienceOne · String Functions
- How does string concatenation work in Java?ComputerScienceOne · String Methods
- How can you define arrays of strings in PHP?ComputerScienceOne · Arrays of Strings