Use curly brackets (docs):
print("<img src='images{$row['name']}'>");
P.S. You can use single quotes for HTML attributes.
Question
I am having trouble with the following:
file.php:
$row['name'] = "hello";
print("<img src=\"images/$row['name']\">");
Desired output:
<img src="images/hello">
This generates a PHP error:
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
What's happening here?
Solution
Use curly brackets (docs):
print("<img src='images{$row['name']}'>");
P.S. You can use single quotes for HTML attributes.