在 PHP 中,下面的代码允许我创建一个字符串而不必转义引号..
$string = <<<EOD
',. whatever <"",'
EOD;
echo $string;
Ruby/Rails 中有类似的东西吗?
最佳答案
Ruby heredocs 几乎相同,只有细微的变化,它们有两种风格:
1) End-of-heredoc 必须在一行的开头:
string = <<EOD
',. whatever <"",'
EOD
puts string
2) End-of-heredoc 前面可以有空格:
string = <<-EOD
',. whatever <"",'
EOD
puts string
关于php - 在 Ruby/Rails 中是否有等同于 <<<EOD 的东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3293384/