在变量中存储图像路径


Storing image path in a variable

我有一个数据库,用于存储用户图像的路径,例如images/profile/950baasfaa88c.jpg。现在,当我尝试将其放入变量并用图像标签包围它时,只会出现空白图像而不是图像本身......

    $profile_picture = $row['profile_image'];
<img src="'.$profile_picture.'" width=50 height=50 />

你还没有回显PHP

<img src="'.$profile_picture.'" width=50 height=50 />

应该是

<img src="<?= $profile_picture ?>" width=50 height=50 />

你需要回显出这个值

<img src="<?php echo $row['profile_image']; ?>" width=50 height=50 />