Home Ask Login Register

Developers Planet

Your answer is one click away!

Mick Sulley February 2016

PHP UK £ symbol inconsistency

I have 2 similar PHP pages, one displays the UK £ symbol correctly, the other displays a black diamond with a ? in it.

In order to diagnose the problem I cut the code down and they are now identical, but still display differently. How can that be??? This is the code `

<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=utf8">

echo '<p>';

echo "£"."123";



While working with the original code it seemed that I could fix one by removing the charset=utf8 but if I removed it from the other it prefixed the £ with a capital A with an accent.

What is happening here?


Marcos Pérez Gude February 2016

You have configured another charset in your apache configuration. Maybe your php are proccessed with ISO-8859-1 and you are defining in your HTML UTF-8. That's an inconsistency. Try to define UTF-8 in your apache configuration.

See this post:

how to change the default encoding to UTF-8 for server

In httpd.conf add (or change if it's already there):

AddDefaultCharset utf-8

Mick Sulley February 2016

I found the answer. The PHP files were saved with different encoding, the one which behaved OK was UTF8, the problem one was Windows-1252. I use Bluefish and it all looked OK in there, but cat the file and I could see the odd character. Thanks for your help Mick

Post Status

Asked in February 2016
Viewed 3,881 times
Voted 8
Answered 2 times


Leave an answer

Quote of the day: live life