PHP Escape Slash Examples

Using Escape Slash

My name is Zubia and I'm learning PHP.

Not Using Escape Slash

My name is Zubia and I'm learning PHP.

Explanation

The escape slash allows PHP to treat a special character as part of the text instead of treating it as PHP syntax. In the first example, the backslash before the apostrophe allows the apostrophe in "I'm" to appear inside a single-quoted string without ending the string too early.

Back to Activity 3