PHP Escape Slash Examples

Example Using an Escape Slash

My name is "Ward" and I am learning PHP.

Example Without an Escape Slash

My name is "Ward" and I am learning PHP.

Explanation

The PHP escape slash is a backslash placed before a special character. In the first example, the backslashes allow quotation marks to appear inside a double-quoted PHP string without ending the string early. The second example avoids escape slashes by using single quotes and concatenating the variable with periods.


Back to Activity 3 Home Page