Dragen Posted September 16, 2007 Share Posted September 16, 2007 I'm getting a very strange result trying to echo a simple pound sign '£'. Here's my code: $currency = '£'; echo $currency; For some reason it's outputting this: £ With the Â... I've tried this as well: echo htmlentities($currency) but I get the same result.. I've never had this problem before and it doesn't6 happen with any other symbols, could anyone suggest an answer? Thanks Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/ Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 Works fine for me but: $currency = '£'; echo $currency.' £ £ '; Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349631 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 yeah.. I don't get it. it works fine if I use either: £ or £ but I need to be able to use just the £ symbol, and convert it using htmlentities, because it's for other people to use who probably wont understand the codes for them. It's a really strange result though... EDIT: If I use htmlentities on it and view the source it outputs: £ Just can't figure out why it's adding the  Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349632 Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 How does it handle when comes from a textbox? Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349635 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 it's not coming from a text box... just a file with a couple of variables at the top which have instructions on how to modify. Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349636 Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 Will it replace? Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349638 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 sorry.. what do you mean? Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349640 Share on other sites More sharing options...
Jessica Posted September 16, 2007 Share Posted September 16, 2007 It's probably the text editor you are using to save your files. Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349642 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 just realised it's not limited to outputting with php... I tried putting £ on the page outside of <?php tags and the same thing happens. Can't be the text editor.. I'm using dreamweaver, which has never given a problem like that before. It also seems to be only on this one file for some reason.. Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349648 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 actually.. it is happenning on other files... All I've got on this file now is this: <?php $currency = '£'; echo $currency; ?> and I'm still getting: £ hmmm.. for some reason it's changed my £ sign in my code up their to the ascii, but it should be the £ symbol. Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349651 Share on other sites More sharing options...
effigy Posted September 16, 2007 Share Posted September 16, 2007 "£" is the UTF-8 encoding for a pound sign. Use <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />. Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349656 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 ah.... I feel stupid thanks! Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349665 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 actually.. It's still not working. I've set the headers. I've got my meta tag as: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> which is what I always use, but it's still outputting £. Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349671 Share on other sites More sharing options...
rucia Posted September 16, 2007 Share Posted September 16, 2007 Try this: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349675 Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 already tried that, thanks Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349676 Share on other sites More sharing options...
effigy Posted September 17, 2007 Share Posted September 17, 2007 If you're saving the script as UTF-8, you need PHP to process it as so--not just the output from PHP, but the code itself. This could be a web server thing; I'm not positive at the moment. Are you using Apache? Link to comment https://forums.phpfreaks.com/topic/69577-strange-results-echoing-%C2%A3/#findComment-349814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.