Bifalgorithm post · Computer science one · String Functions

How do you concatenate strings in PHP?

How do you concatenate strings in PHP? (Computer science one · String Functions) — "PHP has a concatenation operator built into the language. To concatenate on…

Ideas in this flowchart

  • PHP string concatenation
  • PHP includes a concatenation operator built into the language.
  • A period (.) between values joins one or more strings.
  • Concatenation produces a new string.
  • String concatenation example
  • $firstName and $lastName store the values "Tom" and "Waits".
  • $formattedName becomes "Waits, Tom" after concatenation.
  • Concatenation also works with other variable types.
  • $x stores 10 and $y stores 3.14.
  • $s becomes "Hello, x is 10 and y = 3.14".
Feed/

How do you concatenate strings in PHP?

No cover

Channel

Computer science one

1 page

"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\""

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.