阅读量:0
在PHP中,可以使用heredoc语法或nowdoc语法来创建多行字符串,并且可以对字符串进行格式化。下面是一个示例:
<?php // 使用heredoc语法创建多行字符串并进行格式化 $str = <<<EOD This is a multi-line string. We can format it as we like. For example, we can add line breaks and indentation. EOD; echo $str; // 使用nowdoc语法创建多行字符串并进行格式化 $str2 = <<<'EOT' This is another multi-line string. We can format it as we like. For example, we can add line breaks and indentation. EOT; echo $str2; ?>
在上面的示例中,我们使用heredoc语法和nowdoc语法创建了两个多行字符串,并对它们进行了格式化。可以根据需要在字符串中添加换行符、缩进等来使字符串更易阅读。