From the course: Learning PHP
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Single vs. double quotes
- [Instructor] So you can use single or double quotes for strings but what's the difference? Let's take a look. The main difference between single and double quotes is any string in double quotes will be processed by PHP before it's outputted. That means, for example, any variables in strings with double quotes will become their literal value. Let's take a look at an example here where on the left side of the screen, I have my code and on the right side of the screen, I have the result in the browser. I'll type my opening php tag. And then I will create a variable called name. So we'll say name gets Joe. And I'll put Joe in single quotes. Then we'll say echo double quote Hello, comma space name. Remember, PHP prints exactly as we type within the quotes, so we need to add any punctuation and spaces and things like that. Then we'll add our semicolon. We'll save this and we'll fresh the page. You could see it says…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
How PHP works2m 29s
-
(Locked)
Printing on the screen3m 53s
-
(Locked)
Using variables6m 40s
-
(Locked)
Single vs. double quotes7m 3s
-
(Locked)
What are arrays and how do they work?3m 56s
-
(Locked)
Defining arrays8m 10s
-
(Locked)
Challenge: Display basic information on an HTML page36s
-
(Locked)
Solution: Display basic information on an HTML page2m 57s
-
-
-
-
-
-
-
-
-
-