Best Practices: working with long, multiline strings in PHP?

前端 未结 10 2089
感情败类
感情败类 2020-11-27 09:59

Note: I\'m sorry if this is an extremely simple question but I\'m somewhat obsessive compulsive over the formatting of my code.

I have a class that has a function th

10条回答
  •  情深已故
    2020-11-27 10:35

    The one who believes that

    "abc\n" . "def\n"
    

    is multiline string is wrong. That's two strings with concatenation operator, not a multiline string. Such concatenated strings cannot be used as keys of pre-defined arrays, for example. Unfortunately php does not offer real multiline strings in form of

    "abc\n"
    "def\n"
    

    only HEREDOC and NOWDOC syntax, which is more suitable for templates, because nested code indent is broken by such syntax.

提交回复
热议问题