Escape Backslash

Example 1 — Using escape backslashes

Addam said, "PHP is useful."

Example 2 — Not using escape backslashes

Addam said, "PHP is useful."

Explanation

The escape backslash tells PHP to treat the following double quote as part of the string instead of ending it. The backslashes disappear from the displayed output. In the second example, single quotes surround the string, so its internal double quotes need no escaping. Both variables therefore contain the same sentence without causing a syntax error.

Return to Activity 3 index