Special welcome gift. Get 50% off your first courses with code “AS50”. Find out more!

HomeInterviewWhat is the meaning of ‘escaping to PHP’?
courses 20

What is the meaning of ‘escaping to PHP’?

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, InterviewBit.” 

But what if I include double quotes within the string?
“Hello “InterviewBit.”” 

Now I have ambiguity – the interpreter doesn’t know where does 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 \”InterviewBit.\”” 

Any quote that is preceded by a slash is escaped and understood to be part of the value of the string.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

Categories

ads sidebar 1

You May Also Like

Oracle has several modes for shutting down the database: In normal mode, the database is shut down by default. It...
Materialized views are items that contain condensed sets of data from base tables that have been summarized, clustered, or aggregated. They...
Every database in Oracle has a tablespace called SYSTEM, which is generated automatically when the database is created. It also...