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.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化