【发布时间】:2015-07-01 15:48:57
【问题描述】:
我有一个简单的函数,它有两个参数,一个是图片的url,另一个是图片的属性
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。 -
你确定这是你得到的输出吗?输出与您的
echos 不一致。
标签: php html twitter-bootstrap