Escape Slash in PHP

Example without Escape Slash (This one does NOT have escape slash)

Hello, my name is Scott.

Example with Escape Slash (This one HAS escape slash)

Hello, my name is $name.

The escape slash (\) in PHP is used to escape characters that have special meanings in strings. In this example, we used the escape slash to display the literal "$name" instead of parsing the variable. The first example does not use an escape slash, so the variable is not parsed, while the second example uses the escape slash to display "$name" as text.


Back to Home