我已经一个简单的函数,它有两个参数,一个是图像的URL,以及其他用于图像这段代码有什么问题? HTML + PHP
function image_found($url,$attributes)
{
if(@getimagesize($url))
{
echo '<img src="'.$url.'" '.$attributes.'/>';
}
else
{
echo '<img src="'.base_url().'/site_images/image_not_found.svg" '.$attributes.'/>';
}
}
现在
的属性我想要做的就是创建一个可点击的图像,如果图像被发现,现在这是HTML代码
echo '<div class="panel-body">';
echo '<div class="col-md-12 col-lg-12 col-sm-12 text-center">';
$url = base_url().'product_images/'.$result->product_image.'.'.$result->image_type;
$attributes = 'height="200px" width="100%"';
echo '<a href="product.com/full/url">'.image_found($url,$attributes).'</a>';
echo '</div>';
echo '</div>';
,这是我得到
<div class="panel-body">
<div class="col-md-12 col-lg-12 col-sm-12 text-center">
<img src="http://localhost/nsc/product_images/7908076366784972032090.jpg" height="200px" width="100%"/>
<a href="#"></a>
</div>
</div>
我不知道什么是错在这里输出,我使用的引导
在你的函数中使用'return'而不是'echo'。 –
你确定这是你得到的输出吗?输出与你的'echo'不一致。 –