首頁 > 後端開發 > php教程 > html - thinkPHP if标签 怎么判断图片存在不存在??

html - thinkPHP if标签 怎么判断图片存在不存在??

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-06-06 20:18:24
原創
1682 人瀏覽過

后台的新闻列表 如果新闻中没有图片 则让其不显示图片 用if标签怎么实现

<code>                    <td>{$i}</td>
                    <td>{$v.title}</td>
                    <td>{$v.type}</td>                    
                    <td class="text-c">                    
                    <img  src="/static/imghw/default1.png" data-src="__ROOT__/{$v.images}" class="lazy"    style="max-width:90%"  style="max-width:90%" alt="html - thinkPHP if标签 怎么判断图片存在不存在??" >
                    </td>
                    <td>{$v.dateandtime}</td></code>
登入後複製
登入後複製

回复内容:

后台的新闻列表 如果新闻中没有图片 则让其不显示图片 用if标签怎么实现

<code>                    <td>{$i}</td>
                    <td>{$v.title}</td>
                    <td>{$v.type}</td>                    
                    <td class="text-c">                    
                    <img  src="/static/imghw/default1.png" data-src="__ROOT__/{$v.images}" class="lazy"    style="max-width:90%"  style="max-width:90%" alt="html - thinkPHP if标签 怎么判断图片存在不存在??" >
                    </td>
                    <td>{$v.dateandtime}</td></code>
登入後複製
登入後複製

假设你的$v['images'] 没有图片时为空
则判断 <if condition="$v['images'] neq '' "><img src="/static/imghw/default1.png" data-src="__ROOT__/{$v.images}" class="lazy" style="max-width:90%" style="max-width:90%" alt="html - thinkPHP if标签 怎么判断图片存在不存在??" ></if>

要是你的$v['images'] 没有图片时有一个默认值(例如: '/public/index/')
则判断 <if condition="$v['images'] neq '/public/index/' "><img src="/static/imghw/default1.png" data-src="__ROOT__/{$v.images}" class="lazy" style="max-width:90%" style="max-width:90%" alt="html - thinkPHP if标签 怎么判断图片存在不存在??" ></if>

这个不用thinkPHP吧,用PHP就能判断吧?

<code><?php if(isset($v.images)&&!empty($v.images)):?>
    <img  src="/static/imghw/default1.png" data-src="__ROOT__/{$v.images}" class="lazy"    style="max-width:90%"  style="max-width:90%" alt="html - thinkPHP if标签 怎么判断图片存在不存在??" >
<?php endif;?></code>
登入後複製
相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
輸入<html><>後面是怎麼變成<html></html>的
來自於 1970-01-01 08:00:00
0
0
0
HTML與HTML5的差別
來自於 1970-01-01 08:00:00
0
0
0
HTML總結
來自於 1970-01-01 08:00:00
0
0
0
HTML總結
來自於 1970-01-01 08:00:00
0
0
0
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板