PHP Echo a large block of text

后端 未结 11 885
南方客
南方客 2021-01-30 21:00

Im new to PHP and I can\'t figure out what the rules are for using the echo function. For example, if I need to echo a large block of css/js, do I need to add echo to each line

11条回答
  •  不思量自难忘°
    2021-01-30 21:23

    Heredoc syntax can be very useful:

    // start the string with 3 <'s and then a word
    // it doesn't have to be any particular string or length
    // but it's common to make it in all caps.
    echo <<< EOT
        in here is your string
        it has the same variable substitution rules
        as a double quoted string.
        when you end it, put the indicator word at the
        start of the line (no spaces before it)
        and put a semicolon after it
    EOT;
    

提交回复
热议问题