PHP Escape Slash Examples
Using an Escape Slash
Kaleb said, "PHP is useful for web development."
Not Using an Escape Slash
Kaleb said, "PHP is useful for web development."
Explanation
The escape slash tells PHP to treat the character after it as part of the text instead of ending the string. In the first example, backslashes allow double quotation marks to appear inside a double-quoted string. The second example avoids escape slashes by surrounding the entire string with single quotation marks.
Return to Index