ZF-9498: Zend_Currency service ignored

Issue Type: Bug Created: 2010-03-21T10:46:02.000+0000 Last Updated: 2010-03-21T14:20:52.000+0000 Status: Resolved Fix version(s): - 1.10.3 (01/Apr/10)

Reporter: Micha Verboeket (mverboeket) Assignee: Thomas Weidner (thomas) Tags: - Zend_Currency

Related issues: Attachments:


The Zend_Currency service seems to be ignored. When exactly following the documentation 1.10 code examples, this are the results: Expected result: '$ 3.000' Actual result: '$2,000.00' According to the documentation: "The above example will return '$ 3.000' because the 1.000 EUR will be converted by a rate of 2 to 2.000 USD."


Posted by Micha Verboeket (mverboeket) on 2010-03-21T10:52:00.000+0000

Affected component

Posted by Thomas Weidner (thomas) on 2010-03-21T11:49:40.000+0000

Please describe what exactly you mean.

There are about 500 different code examples through the complete documentation.

What did you do, which code did you use and what did you expect? Which ZF release and which PHP release were you using?

We need some more informations to be able to reproduce your failure.

Posted by Micha Verboeket (mverboeket) on 2010-03-21T12:08:30.000+0000

I used the 2 code examples on the English reference guide of the framework version 1.10 (…) I am using php 5.3.0

This is the code I used:

<pre class="highlight"> 
class ZFCustom_CurrencyExchange implements Zend_Currency_CurrencyInterface
    public function getRate($from, $to)
        if ($from !== "USD") {
            throw new Exception('We can only exchange USD');
        switch ($to) {
            case 'EUR':
                return 0.5;
            case 'JPE':
                return 0.7;
       throw new Exception('Unable to exchange $to');


<pre class="highlight"> 
$currency = new Zend_Currency(
        'value'    => 1000,
        'currency' => 'USD',
$service  = new ZFCustom_CurrencyExchange();
// attachons le service de change

$currency_2 = new Zend_Currency(
        'value'    => 1000,
        'currency' => 'EUR',
print $currency->add($currency_2);

The locale is registered with:

<pre class="highlight"> 
Zend_Registry::set('Zend_Locale',new Zend_Locale('en_US'));

And as I said: Expected result: '$ 3.000' Actual result: '$2,000.00'

Posted by Thomas Weidner (thomas) on 2010-03-21T14:20:51.000+0000

Fixed with r21602

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.