Language Problem in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
everurssantosh
Forum Newbie
Posts: 13
Joined: Wed Jun 25, 2008 10:26 am

Language Problem in PHP

Post by everurssantosh »

Hi,

I am trying to show five different languages in my website. I am not using any other tool to achieve this task. Basically, I have stored the all language values in a language file. While in my pages, I include the language page and call the language varriables. I manage the languge value like english, spanish etc in my session varriable.

My problem is: There are some spcial characters in languages like italian, german for example : è,á ,ó ,Nº ,ñ etc and these are not shown properly in my browser. It shows like a sqare box which makes the complete sentense not readable and looks ugly. I think we need to install some kind of package in the client browser in order to show these special characters!! but honestly speaking, I have no idea how to solve it.

Any help in this regard is higly appritiated !!

Thank you
Santosh
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Language Problem in PHP

Post by onion2k »

It's an encoding problem. You need to make sure you serve the pages in a language encoding that supports the characters you're using ... UTF-8 is probably the right one for you unless you're serving pages in a non-western alphabet (eg Russian, Arabic, Chinese etc).

There are lots of ways to set the encoding.. I use a header like "header("Content-type: text/html; charset=utf8");", but you can set it in Apache's config file, or specify it in the HTML using a charset attribute or a meta tag... what you need to use depends entirely on the way your site it coded.

Whatever the case though, you don't need users to install anything. Browsers can do different languages no problem.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Language Problem in PHP

Post by Kieran Huggins »

you need to specify the character encoding - UTF-8 is likely the best choice.

edit: er... what onion said.
everurssantosh
Forum Newbie
Posts: 13
Joined: Wed Jun 25, 2008 10:26 am

Re: Language Problem in PHP

Post by everurssantosh »

what are the changes that i need to apply to my config file !!!
and if it is possible I can better add the piece of code in my pages itself..

kindly specify the code to be added for unicode ..

thanks
santosh
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Language Problem in PHP

Post by Kieran Huggins »

onion2k wrote:header("Content-type: text/html; charset=utf8");
Post Reply