2017-04-24 44 views
-2

我有這樣的PHP變量,PHP和JavaScript塊

<div class="autcp"> 
     <?php 
     if($GLOBALS['q']==""){ 
      echo ""; 
     }else if($GLOBALS['q']=="bb"){ 
      echo "cc"; 
     } 
     ?> 
</div> 

CSS

width: 301px; 
padding: 20px 22px 18px 22px; 
box-shadow: 0 2px 3px rgba(0,0,0,0.06); 
border: 1px solid rgba(150,150,150,0.3); 
border-bottom-color: rgba(125,125,125,0.3); 

我想要做的是不顯示任何東西,如果它是空的

+2

將您的代碼更改爲此if'!empty($ GLOBALS ['q'])&& $ GLOBALS ['q'] ==「bb」) echo「cc」; }' –

+0

如果它是空的,你不想顯示空的div是不是? – JYoThI

回答

0
.autcp{ 
    width: 301px; 
    padding: 20px 22px 18px 22px; 
    box-shadow: 0 2px 3px rgba(0,0,0,0.06); 
    border: 1px solid rgba(150,150,150,0.3); 
    border-bottom-color: rgba(125,125,125,0.3); 
} 
    <?php 
    if(!empty($GLOBALS['q']) && $_GLOBALS['q']=='bb'){ 
     ?> 
<div class="autcp"> 
<?php 
echo "cc"; 
?> 
</div> 
<?php 
    } 
    ?>