When we create a string variable we can use single R double quotes.
For example here we have two strings one enclosed in single quotes.
And the other in double quotes you can use either.
But the quote used at the start and the end have to match.
If you want to insert a quote character into a string for example like this in a single quoted string
then you can't just use the quote character as P P will think that's the end of the string.
You can either use the other quotes to enclose the string.
Ah you can escape the quote inside the string by putting a backslash in front of it.
If we print these two out.
Then the strings are printed out containing the quote inside the string.
If we're using double quotes around the string we can also use this method to insert some special characters
for example a new line character or a tab.
For example if I add a new variable containing three days of the week and I separate these with a backslash
N and then print this out.
In the browser they appear on one line because that's how the browser shows new line characters by default.
But if we view the source.
We can see that each backslash N. character has been converted into a new line.
Will learn more later on about how the browser interprets h.t. dml.
We also just saw how to concatenate strings.
For example we can come katin 8 a literal string and a variable.
And in the browser we get the strings join together.
We can also insert the variable directly into the string.
If were using double quotes for example like this.
This is called variable interpolation.
And in the browser the result is the same.
Finally if you want to insert a variable into a string and it's not clear where the variable ends.
For example if you have some letter characters straight after it then you can surround the variable
with curly braces like this.
If you are not interpolating variables are inserting special characters.
It doesn't really matter if you use single or double quotes using single quotes used to be ever so slightly
faster.
But in recent versions of P 8 p It doesn't really make any difference.
Likewise with concatenation interpolation.
Use which ever you think makes your code easier to read unless you can Catton ating hundreds of strings.
There's no real difference in performance between the two.