Документация
HTML CSS PHP PERL другое

Section 4.8.  Multiline Strings

 
Previous
Table of Contents
Next

4.8. Multiline Strings

Lay out multiline strings over multiple lines.

If a string has embedded newline characters, but the entire string won't fit on a single source line, then break the string after each newline and concatenate the pieces:


    $usage = "Usage: $0 <file> [-full]\n"
             . "(Use -full option for full dump)\n"
             ;

In other words, the internal appearance of the string should mirror its external (printed) appearance as closely as possible.

Don't, however, be tempted to make the newline implicit, by wrapping a single string across multiple lines, like so:

    $usage = "Usage: $0 <file> [-full]
    (Use -full option for full dump)
    ";

Even though actual line breaks inside such a string do become newline characters within the string, the readability of such code suffers severely. It's harder to verify the line structure of the resulting string, because the first line is indented whilst the remaining lines have to be fully left-justified. That justification can also compromise your code's indentation structure.

    Previous
    Table of Contents
    Next
    © 2000- NIV