有两种方法把变量替换到字符串中——简单的方法和复杂的方法。 简单的方法是把变量名放在双引号字符串或heredoc中: $who = ‘Kilroy’; $where = ‘here’; echo “$who was $where”; Kilroy was here 复杂的方法是把要替换的变量用大括号括起来。这种方法可以用于消除歧义或替换数组查找。大括号的经典作用是把变量名从周围的文本中分隔出来: $n = 12; echo “You are the {$n}th person”; You are the 12th person 如果没有大括号的话,PHP就会尝试打印出变量$nth的值。 和一些