dorisdong0514 2018-01-15 17:04
浏览 77
已采纳

编程时会有什么行结束?

There is a thing make me puzzled in 2.2 of PSR-2 document.

enter image description here

All I know is that different os use different line ending as default :

  • windows:CRLF
  • unix:LF
  • mac:CR

I want to know why should "All PHP files MUST use the Unix LF(linefeed) line ending" . Or in other word, what will line ending cause ?

  • 写回答

3条回答 默认 最新

  • douxiapi4381 2018-01-15 17:10
    关注

    The main reason behind this is scv (Source Code Versioning), where changing line-endings cause unnecessary differences and conflicts.

    Secondly, we usually serve our services on Linux, which is based on Unix, which use the LF file ending.

    The first one causes the need of a Standard, and the second one tells you why you should use LF Standard.

    windows:CRLF = '
    '
    unix:LF      = '
    '
    mac:CR       = '' // macOS also changed to LF a long time ago btw.
    

    Update: also note that, whilst PHP - and imo. all the other scripting languages - doesn't really depend on a specific line-ending, in other languages this might cause issues.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键