The PHP parsing engine needs a way to differentiate PHP code from other page elements. The mechanism to achieve this is known as ‘escaping to PHP’. Escaping a string means reducing ambiguity in quotes used in that string.
For example, when you’re defining a string, you surround it in either double quotes or single quotes:
"Hello, Brijesh."
But what if I include double quotes within the string?
"Hello "Brijesh.""
Now I have ambiguity - the interpreter doesn’t know where my string end. If I want to keep my double quotes, I have various options. I could use single quotes around my string:
‘Hello "InterviewBit."’
Or I can escape my quotes:
"Hello "Brijesh.""
Any quote that is preceded by a slash is escaped and understood to be part of the value of the string.