2010-04-28 85 views
-1

如何在一個條件下包含下面的整個語句?所以如果變量$ uprice = 0那麼我不想顯示下面的任何代碼有條件的PHP幫助

<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item- >getWeeeTaxAppliedAmount()): ?> 

    <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> 

    <?php else: ?> 
    <?php echo $this->helper('checkout')->formatPrice($_item- >getCalculationPrice()) ?> 
    <?php endif; ?> 

回答

3

這個??

<?php if ($uprice === 0): ?>  
    <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item- >getWeeeTaxAppliedAmount()): ?>  
    <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>  
    <?php else: ?> 
    <?php echo $this->helper('checkout')->formatPrice($_item- >getCalculationPrice()) ?> 
    <?php endif; ?> 
<?php endif; ?> 
+0

+1 ...你搖滾! :P – zaf 2010-04-28 16:55:26

+0

@zaf:謝謝................. – Sarfraz 2010-04-28 17:02:29

1
if ($uprice == 0){ 
    if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') 
     && $_item- >getWeeeTaxAppliedAmount()) 
    { 
    echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice() 
     +$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); 
    } else { 
    echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) 
    } 
}
1

我覺得你的代碼將是包含所有在一個PHP代碼塊的可讀性,並作爲Sarfraz表示它不應該是簡單的周圍的東西加入的條件?