本文整理汇总了PHP中Currency::format方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::format方法的具体用法?PHP Currency::format怎么用?PHP Currency::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::format方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_formats_amount_3
public function test_formats_amount_3()
{
$eur = new Currency('EUR');
$this->assertEquals('560,00', $eur->format(new Decimal2('560.00')));
$this->assertEquals('-1.560,00', $eur->format(new Decimal2('-1560.00')));
$this->assertEquals('-100.000.000.000,00', $eur->format(new Decimal2('-100000000000.00')));
}
示例2: getItemProducts
public function getItemProducts($results = array(), $setting)
{
global $registry;
$this->load->model('pavnewsletter/product');
$this->load->model('tool/image');
require_once DIR_SYSTEM . "/library/currency.php";
$currency = new Currency($registry);
$products = array();
$i = 0;
foreach ($results as $result) {
if ($i < $setting['limit']) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
} else {
$image = false;
}
$price = $currency->format($result['price'], $setting['currency']);
if (isset($result['special'])) {
$special = $currency->format((double) $result['special'], $setting['currency']);
} else {
$special = false;
}
$products[] = array('product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'href' => str_replace("/admin/", "/", $this->url->link('product/product', 'product_id=' . $result['product_id'])));
}
$i++;
}
return $products;
}
示例3: getById
public function getById()
{
$product_id = $this->request->get['product_id'];
$this->load->auto('store/product');
$this->load->auto('image');
$this->load->auto('tax');
$this->load->auto('currency');
$tax = new Tax($this->registry);
$currency = new Currency($this->registry);
$strProducts = '';
$product = $this->modelProduct->getById($product_id);
$tags = $this->modelProduct->getTags($product_id);
if (isset($this->request->get['format']) && !empty($this->request->get['format'])) {
$strProducts .= "Producto: " . $product['name'] . "\n";
$strProducts .= "Precio: " . $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))) . "\n";
//TODO: cureency format
$strProducts .= "URL: " . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/");
if ($tags) {
foreach ($tags as $key => $tag) {
$ntag = $key + 1;
$strProducts .= "\nTag " . $ntag . ": " . Url::createUrl("product/search", array("keyword" => $tag['tag']), "NONSSL", HTTP_CATALOG . "/") . "\n";
}
}
$strProducts .= "\n";
echo $strProducts;
} else {
$strProducts .= "<div style='margin:5px;padding:3px;background:#FFF;float:left;border:dotted 1px #ccc;width:100px;display:block;text-align:center'>";
$strProducts .= "<br><p><a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/") . "'>" . $product['name'] . "</a></p>";
if (empty($product['image'])) {
$strProducts .= "<a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/") . "'>";
$strProducts .= "<img src='" . NTImage::resizeAndSave('no_image.jpg', 50, 50) . "' alt='" . $product['name'] . "'>";
$strProducts .= "</a>";
} else {
$strProducts .= "<a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id'])) . "'>";
$strProducts .= "<img src='" . NTImage::resizeAndSave($product['image'], 50, 50) . "' alt='" . $product['name'] . "'>";
$strProducts .= "</a>";
}
$strProducts .= "<input type='hidden' name='" . $product['product_id'] . "' value='" . $product['product_id'] . "'>";
$strProducts .= "<br><b>" . $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))) . "</b><br>";
if ($tags) {
foreach ($tags as $key => $tag) {
$strProducts .= " <a href='" . Url::createUrl("product/search", array("keyword" => $tag['tag']), "NONSSL", HTTP_CATALOG . "/") . "' style='font:normal 9px verdana'>" . $tag['tag'] . "</a> ";
}
}
$strProducts .= "<br></div>";
echo $strProducts;
}
}
示例4: date
$currentMonth = date('m');
$pastMonth = $currentMonth == 1 ? 12 : $currentMonth - 1;
$currentMonthName = date('F');
$pastMonthName = date('F', mktime(0, 0, 0, $pastMonth, 1, $currentYear));
$daysCurrentMonth = date("t");
?>
<div class="well" >
<strong>Estimated revenue</strong>
<?php
$sales = DbHelper::selectRows(TBL_SALES, $whereFilterApp . ' AND ' . SALE_ORDER_CHARGED_DATE . '>="' . $currentYear . '-' . $pastMonth . '-01"', SALE_ORDER_CHARGED_DATE . ' ASC', '(SELECT SUM(' . SALE_CHARGED_AMOUNT_MERCHANT_CURRENCY . ') FROM ' . TBL_SALES . ' WHERE MONTH(' . SALE_ORDER_CHARGED_DATE . ')=MONTH(DATE_SUB(NOW(), INTERVAL 1 MONTH)) AND YEAR(DATE(' . SALE_ORDER_CHARGED_DATE . '))=' . $currentYear . ' ) past, ' . '(SELECT SUM(' . SALE_CHARGED_AMOUNT_MERCHANT_CURRENCY . ') FROM ' . TBL_SALES . ' WHERE MONTH(' . SALE_ORDER_CHARGED_DATE . ')=MONTH(CURDATE()) AND YEAR(DATE(' . SALE_ORDER_CHARGED_DATE . '))=' . $currentYear . ' ) current, MONTH(CURDATE())', null, null, false);
if (empty($sales)) {
?>
<span class="muted text-i" >No record found.</span><?php
} else {
$s =& $sales[0];
echo $pastMonthName, ' : ', $currency->format($s[0]), ' – ', $currentMonthName, ' : ', $currency->format($s[1]);
?>
<span class="badge" style="background-color:<?php
echo $s[1] > $s[2] ? '#99cc00' : ($s[1] == $s[2] ? '' : '#ff4444');
?>
">
<i class="icon-white <?php
echo $s[1] > $s[2] ? 'icon-arrow-up' : ($s[1] == $s[2] ? 'icon-minus' : 'icon-arrow-down');
?>
" ></i>
</span>
<?php
}
?>
</div>
示例5: testRealFormat
/** @depends testConstructEmpty
* @depends testDecimalSymbolFormat
* @depends testDecimalSeparatorFormat
* @depends testThousandsSeparatorFormat
*/
public function testRealFormat()
{
$curr = new Currency("Test", "\$", ".", ",", "\$ #,##0.00", 1.2, true, true);
$this->assertEquals("\$ 1,234.99", $curr->format(1234.99));
$this->assertEquals("\$ 11,234.99", $curr->format(11234.99));
$this->assertEquals("\$ 10.50", $curr->format(10.5));
$this->assertEquals("\$ 0.00", $curr->format(0));
$curr = new Currency("Test", "€", ",", " ", "#,##0.00 \$", 1.2, true, true);
$this->assertEquals("1 234,99 €", $curr->format(1234.99));
$this->assertEquals("11 234,99 €", $curr->format(11234.99));
$this->assertEquals("10,50 €", $curr->format(10.5));
$this->assertEquals("0,00 €", $curr->format(0));
}