Trying to get the euro symbol using chr(128)

ziiweb picture ziiweb · Feb 3, 2011 · Viewed 38.4k times · Source

I expected this code:

define('EURO_SIMBOLO', chr(128));
$euro = EURO_SIMBOLO;
var_dump($euro);

to show the symbol, but it doesn't. Why does this happen?

Answer

netcoder picture netcoder · Feb 3, 2011

If you want to go with Unicode, UTF-8 more specifically, which I prefer because of its flexibility, you can output the Euro sign using:

echo "\xE2\x82\xAc"; // 3 bytes-long multibyte character