PHP Escape Slash Examples

Example Using an Escape Slash

She said, "Hello Sarah!"

Example NOT Using an Escape Slash

She said, "Hello Sarah!"

Explanation

The PHP escape slash, or backslash, allows special characters such as quotation marks to appear inside a string without ending the string. In the first example, the backslashes allow double quotation marks to appear inside a double-quoted string. The second example avoids escape slashes by using single quotes around the string instead.

Back to Index