I understand that:
'\n' // literally the backslash character followed by the character for lowercase n
"\n" // interpreted by php as the newline character
But for the life of me, I can’t understand why '\n' === '\\n'. In my mind, '\\n' would equal three separate characters: two separate backslashes, followed by the letter n.
Why is '\n' === '\\n' true in PHP?
The backslash is still an escape character in single-quoted strings (it escapes literal single quotes).
This is illegal for instance (since the backslash escapes the closing quote):
So
\\must map to a literal backslash to avoid inadvertent escaping.