PHP Escape Slash


Without Escape Slash

Mona said 'Hello!'

With Escape Slash

Mona said "Hello!"

Explanation

In PHP, an escape character is a backslash \ followed by the character you want to insert. An illegal character is a double quote inside a string that is surrounded by double quotes, ex: "Mona says "Hi" to her friend." Running that code would return an error. To fix this, we can use the \ key before our quotes ex: "Mona says \"Hi\" to her friend." to run it without an error as shown in my example above.