我试图将变量的值放在行内:
$email .= "What do you need the container for?: $json['purpose']";
但是我收到了这个错误:
syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
如何解决此问题?
答案 0 :(得分:5)
解决方案一(附上{}):
$email .= "What do you need the container for?: {$json['purpose']}";
解决方案二(逃脱):
$email .= "What do you need the container for?: ".$json['purpose']."";
他们都工作:)