PHP中的数组变量插值


Array-variable interpolation in PHP

我有以下问题:

file.php:

$row['name'] = "hello";
print("<img src='"images/$row['name']'">");
所需输出:

     <img src="images/hello">

生成一个PHP错误:

    Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), 
    expecting identifier (T_STRING) or variable (T_VARIABLE)
 or number (T_NUM_STRING) in 
/path/to/file/file.php on line NN

这是怎么回事?

使用大括号:

print("<img src='images{$row['name']}'>");

注:HTML属性可以使用单引号