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

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -