In PHP do i need to escape backslashes?

后端 未结 6 1047
予麋鹿
予麋鹿 2020-11-30 10:09

I think this may be a stupid question, but I am quite confused whether I need to escape backslash in PHP.

echo \'Application\\Models\\User\'; prints Applicat         


        
6条回答
  •  没有蜡笔的小新
    2020-11-30 10:27

    In single quoted strings only the escape sequences \\ and \' are recognized; any other occurrence of \ is interpreted as a plain character.

    So since \M and \U are no valid escape sequences, they are interpreted as they are.

提交回复
热议问题