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 Quote Link to comment 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.' £ £ '; Quote Link to comment 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  Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 Will it replace? Quote Link to comment Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 sorry.. what do you mean? Quote Link to comment 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. Quote Link to comment 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.. Quote Link to comment 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. Quote Link to comment 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" />. Quote Link to comment Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 ah.... I feel stupid thanks! Quote Link to comment 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 £. Quote Link to comment 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" /> Quote Link to comment Share on other sites More sharing options...
Dragen Posted September 16, 2007 Author Share Posted September 16, 2007 already tried that, thanks Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.