koşullu php yardım

2 Cevap php

Nasıl bir durumda aşağıda tüm bu ifadeyi kapatırız? Yani değişken $ uprice = 0 sonra aşağıda kod herhangi görüntülemek için istemiyorsanız

   <?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; ?>

2 Cevap

Bu?

<?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; ?>

Ben senin kod bir php blok içinde tüm içeren daha okunabilir olacağını düşünüyorum, ve Sarfraz söylediğim gibi şeyler etrafında bir koşul ekleyerek kadar basit olmamalı?

<?php 
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());
    }
}
?>