string - Why is '\n' === '\\n' true in php? -


i understand that:

'\n' // literally backslash character followed character lowercase n "\n" // interpreted php newline character 

but life of me, can't understand why '\n' === '\\n'. in mind, '\\n' equal 3 separate characters: 2 separate backslashes, followed letter n.

why '\n' === '\\n' true in php?

the backslash still escape character in single-quoted strings (it escapes literal single quotes).

this illegal instance (since backslash escapes closing quote):

$path = 'c:\'; 

so \\ must map literal backslash avoid inadvertent escaping.


Comments

Popular posts from this blog

Glib GIOChannel -

jsp - java.sql.SQLException: [Microsoft][ODBC Microsoft Access > Driver] Too few parameters. Expected 1 -

delphi - When I encode/decode SMS PDU (GSM 7 Bit) user data, do I need prepend the UDH first? -