【发布时间】:2020-05-03 13:10:12
【问题描述】:
我想使用 PHP 显示图像。这是我尝试过的方法,但它不起作用。
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<div class="container">
<?php
$img_name = echo $row['img_name']; //I get it from the database
img_block($img_name); //Display the image here.
//Function to display image
function img_block(img_src) {
// e.g. img_src = cat.jpg;
$img_input = "images/" . img_src;
$set_img = '<img class="media-object-ph" src="'.$img_input.'" width="380" height="290" alt="...">';
return $set_img;
}
?>
</div>
</body>
</html>
提前谢谢你。
【问题讨论】:
-
尝试将
$img_input更改为$img_input = "./images/ ... "