PHP Escape Slash Examples

Example 1: Using Escape Slash

My name is Charles and I said, "PHP is interesting to learn."

Example 2: Not Using Escape Slash

My name is Charles and I said, "PHP is interesting to learn."

Explanation

The escape slash, also called a backslash, allows special characters such as quotation marks to appear inside a PHP string without ending the string. In the first example, I used backslashes before the double quotation marks. In the second example, I used single quotes around the PHP string, so the double quotation marks inside the sentence did not need escape slashes.

Back to Activity 3 Home