From the course: PHP for Non-Programmers
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Dealing with quotes and other special characters - PHP Tutorial
From the course: PHP for Non-Programmers
Dealing with quotes and other special characters
- When you're printing strings, you'll run into some issues. Like, what if you have a single quote in a string you want to print? Or what if you have double quotes in a string where you're using those double quotes? Luckily, there are what's called escape characters. And the clearest example is the one you see on screen here where we have a echo statement using double quotes but we also have double quotes in the string. So when we say echo "Joe's nickname in high school was Joey Calzone and we have double quotes here, you could see the text highlighting changes and if we click run, then we get an unexpected error. This error is caused and the code is not executed because before Joey, we end the string, before Joey, we end the string, making anything after it unexpected to the PHP processor. Instead, we need to proceed these double quotes with a back slash, with a back slash, this back slash is called an escape…
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.