0

I'm trying to format foreign currencies. I discovered that the money_format() function doesn't work on Windows and is deprecated as of PHP 8.0.

I am trying this code below and I have not seen a result of my efforts.

Does this function work on Windows? I also want to know if my viewer is interacting with the web page, and they are on a Windows machine, am I going to need a fall back for this function or will they see the proper result from my effort.

<?php 
$fmt = numfmt_create( 'de_DE', NumberFormatter::CURRENCY ); 
echo numfmt_format_currency($fmt, 1234567.891234567890000, "EUR")."\n"; 
echo numfmt_format_currency($fmt, 1234567.891234567890000, "RUR")."\n";

Any help is greatly appreciateed.

Mark
  • 167
  • 1
  • 3
  • 13
  • _"I have not seen a result of my efforts"_ What does this mean? Are you getting an error? Is your output different than what you expected? – Alex Howansky Feb 07 '22 at 20:23
  • This may answer your question https://stackoverflow.com/a/6370792/10213537 – Ameer Feb 07 '22 at 20:23
  • 3
    _"am I going to need a fall back for this function"_ Whether or not the web page visitor is on Windows doesn't matter -- the function is executed server-side. – Alex Howansky Feb 07 '22 at 20:24
  • There's no output when viewing this through my browser. Is it compatible with Windows? – Mark Feb 07 '22 at 20:28
  • Ameer, I tried that link and the code. It seems it might not be compatible with Windows? – Mark Feb 07 '22 at 20:30
  • I see Ameer. I need to install an extension for it to work. Thanks! – Mark Feb 07 '22 at 20:33
  • Ameer, I followed the link and followed their direction, but it seems that it still doesn't work. I'm on Windows 10 using an Apache server. I uncommented the extension in the php.ini file then, I copied the dll files to my bin directory in Apache and also a copy in php 8. I restarted the Apache server,, but it still doesn't work. Can you steer me in the right direction? The php example above doesn't produce any results on my end. – Mark Feb 07 '22 at 22:37
  • Alex, I'm not getting any output from my end. – Mark Feb 07 '22 at 22:49
  • Your code prints `1.234.567,89 €` and `1.234.567,89 RUR` (PHP 8.0.14 on Windows 10). I suspect "doesn't work" means you're getting a blank screen. That means that you haven't configured PHP to display errors. – Álvaro González Feb 08 '22 at 18:37
  • Alvaro, my environment is set to display errors and error reporting. There is still no output according to the code above. – Mark Feb 09 '22 at 21:52
  • I think on Windows you need to enable the php.intl.dll file in your php environment. Not only do you have to enable it, but there are other procedures that need to be implemented for it to work properly on WIndows. That includes dependency files. – Mark Feb 09 '22 at 21:55

0 Answers0