duanbage2161 2012-11-08 07:04
浏览 14

反斜杠 - 这意味着什么

What is difference between \ and \\?

 echo $path_1="C:\wamp\www\practice\";

Output shows error:

Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN

 echo $path_1="C:\\wamp\\www\\practice\\";

Output:

C:\wamp\www\practice\

Instead of printing C:\\wamp\\www\\practice\\ it prints C:\wamp\www\practice\

  • 写回答

2条回答 默认 最新

  • drf97973 2012-11-08 07:10
    关注

    Typically in programming the character \ used between normal double quotes " is an escape character for special characters, making it a special character. So to display the \ you have to escape it with another \.

    I would also mention that the reason you received a Parse Error is because the ending \ you used in your first example escapes the double quote so the end of line could not be parsed.

    评论

报告相同问题?