我想在PHP中回显动态图像路径。我有这样的代码,工程通过PHP回声一个动态的HTML图像路径
<?php
//this code works
$image = '<img src="img/newlogo.jpg">';
echo($image);
?>
//gives me an image
而这个代码不
<?php
//this code doesn't
$lineofstring='newlogo.jpg';
$image = '<img src="img/$lineofstring">';
echo($image);
?>
$ lineofsting实际上将是存储在其中一个行充满了MySQL数据库的图像路径,例如:pictureabc.jpg,第二行是picturexyz.jpg等
我试图将搜索到的imagepath名称传递到$ lineofstring,然后echo'd,但没有图片出来。我哪里错了?
使用双引号。 – bfavaretto 2012-04-28 01:23:45