[英]Hide a div if php echo content is empty
<div class="botontour"><a href="<?php echo $currentItem['video'];?
>">Video Tour 3D</a></div>
I want to hide the entire "botontour" div if the php echo has no return. 如果php echo没有返回,我想隐藏整个“ botontour” div。
<?php
if(isset($currentItem['video']) && !empty($currentItem['video'])){
?>
<div class="botontour"><a href="<?= $currentItem['video'];?>">Video Tour 3D</a></div>
<?php } >
empty — Determine whether a variable is empty empty —确定变量是否为空
<?php
if(!empty($currentItem['video'])) { ?>
<div class="botontour"><a href="<?php echo $currentItem['video'];
>">Video Tour 3D</a></div>
<?php } ?>
You can use strlen() : http://php.net/manual/fr/function.strlen.php 您可以使用strlen(): http : //php.net/manual/fr/function.strlen.php
<?php if(strlen($currentItem['video']) != 0) { ?>
<div class="botontour"><a href="<?php echo $currentItem['video'];?
>">Video Tour 3D</a></div>
<?php } ?>
Or Empty() : http://php.net/manual/fr/function.empty.php 或Empty(): http : //php.net/manual/fr/function.empty.php
<?php if(!empty($currentItem['video'])) { ?>
<div class="botontour"><a href="<?php echo $currentItem['video'];?
>">Video Tour 3D</a></div>
<?php } ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.