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
Post a Comment