Code: Select all
echo '<img src="' .$product['img'] .'" alt=" ' .$product['name']. ' ">';
could't it just be :
Code: Select all
echo '<img src=" .$product['img'] ." alt=" .$product['name']. ">';
Moderator: General Moderators
Code: Select all
echo '<img src="' .$product['img'] .'" alt=" ' .$product['name']. ' ">';
Code: Select all
echo '<img src=" .$product['img'] ." alt=" .$product['name']. ">';
Code: Select all
<img src=/path/to/image.png alt=Name of the product>No. You've opened a single quote and not closed it, so the . will be echoed as a literal period rather than treated as a concatenation operator. Moreover, variables are not parsed inside single quotes.gautamz07 wrote:could't it just be :
Code: Select all
echo '<img src=" .$product['img'] ." alt=" .$product['name']. ">';
Code: Select all
echo "<img src='{$product['img']}' alt='{$product['name']}'>";Code: Select all
echo "<img src=\"{$product['img']}\" alt=\"{$product['name']}\">";Code: Select all
echo '<img src="' .$product['img'] .'" alt=" ' .$product['name']. ' ">';
Code: Select all
echo '<img src=" .$product['img'] ." alt=" .$product['name']. ">';
Yes. As Christopher just said, the " quotes were for the HTML inside the strings and the ' quotes were for the PHP strings themselves.gautamz07 wrote:So @Requinix you mean to say :
echo '<img src=" " >';
the above part is for the html and inside that the :
' .$product['img'] .'
is the PHP ???
the mismatched quotes were accidental and it was supposed to read likegautamz07 wrote:could't it just be :
Code: Select all
echo '<img src=" .$product['img'] ." alt=" .$product['name']. ">';
Code: Select all
echo "<img src=" .$product['img'] ." alt=" .$product['name']. ">";