在php中从数组链接页面上的图像
为什么这不起作用在php中从数组链接页面上的图像,php,Php,为什么这不起作用 <?php $computers = array(); $computers[101] = array( "name" => "phantom NXZT", "img" => "img/phantom.jpg", "cpu" => "Intel i7 4770K Quadcore",
<?php
$computers = array();
$computers[101] = array(
"name" => "phantom NXZT",
"img" => "img/phantom.jpg",
"cpu" => "Intel i7 4770K Quadcore",
"gpu" => "GTX 780 3GB GDDR5",
"ram" => "16GB Corsair 1800mhz",
"hdd" => "Seagate 2TB Hard Drive",
"ssd" => "SanDisk 120GB Solid State",
"price" => 1200
);
?>
<img src="<?php echo $computers["img"];?>">
">
这是一个坏掉的img链接,我想让它在图像src中显示图像url。我不明白为什么它不工作请帮助?因为[101]:)
“>
嗯,对不起,KA_-lin首先回答了这个问题。@KA_-lin-很好的答案,加上双引号应该被
img
周围的单引号所取代……而且,以前将$computers
定义为数组是完全没有用的……旁注:要使其有效,请添加alt
-属性。【OT】我是唯一一个明白这一点的讽刺的人吗?你认为你需要用单引号替换img
周围的双引号吗?@mojorisin:nosweat@KA_lin但是,我没有抄袭你的答案;)@mojorisin先生:用单引号引出来,这样我才能相信你:)
<img src="<?php echo $computers[101]['img'];?>">