Concept
How can strings be concatenated in PHP?
ComputerScienceOne / String Concatenation
"Strings in PHP can be concatenated (combined) in several different ways. One way you can combine strings is by using the concatenation operator. In PHP the string concatenation operator is a single period.\n\n1 $s = \"Hello\";\n\n2 $t = \"World!\";\n\n3 $msg = $s . \" \" . $t; //msg contains \"Hello World!\"\n\nAnother way you can combine strings is by placing variables directly inside a string. The variables inside the string are replaced with the variable’s values.\n\nExample:\n\n1 $x = 13;\n\n2 $name = \"Starlin\";\n\n3 $msg = \"Hello, $name, your number is $x\";\n\n4 //msg contains the string \"Hello, Starlin, your number is 13\""
Related Ideas
- How do you concatenate strings in PHP?ComputerScienceOne · String Functions
- How does string concatenation work in Java?ComputerScienceOne · String Methods
- How can you create and reassign strings in PHP?ComputerScienceOne · Basics
- What are PHP strings and how should they be treated?ComputerScienceOne · Basics
- How can you compute a substring in PHP?ComputerScienceOne · String Functions
- How are PHP strings copied and modified by character?ComputerScienceOne · Basics
- How can you determine the length of a PHP string?ComputerScienceOne · String Functions
- How can you extract substrings from a string in PHP?ComputerScienceOne · Arrays of Strings