magento价格getPrice()值 - php

function getDescriptionHtml($tpl, $p){
    $out = "";
    $pr = $p["product"];

    if(Mage::getStoreConfig('featuredproducts/displayoptions/title') == 'description'){
        $out .= "<ins><h4>{$pr->getName()}</h4></ins>";
    }
    $out .= "<span class=\"description\"".
            (!Mage::getStoreConfig('featuredproducts/displayoptions/description') ?
                    "style=\"display:none;\""
                :
                    ""
            )
            .">{$p['description']}</span>";
    $out .= "<ins><div>".
            (Mage::getStoreConfig('featuredproducts/displayoptions/price') ?
                    "<span style=\"font-size:45px\">{$pr->getPrice()}</span>"
                :
                    ""
            )       
            ."".
            (Mage::getStoreConfig('featuredproducts/displayoptions/bnb') ?
                    "<div><button style=\"postion:relative;margin-left:80px;margin-top:140px\" class=\"form-button\" onclick=\"setLocation('{$p["url"]}')\"><span>{$tpl->__('Buy Now')}</span></button></div>"
                :
                    "")
            ."
            </div></ins>";
    return $out;        
}

根据显示的代码,当我使用$ pr-> getPrice()时,其输出看起来像299.0000,但我希望它像299.00。我怎样才能做到这一点?

参考方案

尝试number format

"<span style=\"font-size:45px\">{" . number_format($pr->getPrice(), 2) . "}</span>"

jQuery不起作用 - php

我正在使用带有ajax的jquery。有时,给出错误$未定义。这是我的代码:<script language="javascript" type="text/javascript"> var base_path="<? echo $this->baseUrl().'/…

Div单击与单选按钮相同吗? - php

有没有一种方法可以使div上的click事件与表单环境中的单选按钮相同?我只希望下面的div提交值,单选按钮很丑代码输出如下:<input id="radio-2011-06-08" value="2011-06-08" type="radio" name="radio_date&#…

PHP-复选框组 - php

我有一个需要发布的表单复选框组。<input type="checkbox" value="true" checked name="chk0[]"> <input type="checkbox" value="false" name=…

PHP:正则表达式匹配短语不包含特定单词 - php

我已经厌倦了寻找足够接近的例子,花时间寻求一些快速帮助!这是我的代码:preg_match_all( '#<li.*?>.*?</li>#s', $card_html, $activity ); 我想对其进行修改,以使<li.*?>排除单词Unplayed。 (单词出现在.*?之后和>之前。编辑:…

jQuery如果选中则启用动态输入文本 - php

我正在使用PHP生成具有表格的表格,例如:<table class="table table-hover"> <thead> <tr> <th class="table-checkbox"> </th> <th> Description </…