0

I have been trying to display my text in PHP but I am getting issue from Turkish characters it display it as ıııööö

I am reading data from MySQL but the issue is from the PHP. Please what it is missing?

My code is simple:

<?php

echo "ş i ü ğ";

?>
Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51

2 Answers2

3

Check, if your website is in UTF-8.

Just copy following code to the <header> tag of your documment:

<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

Or you can use just shorter version according to HTML5. Compatibility is fine:

<meta charset='utf-8'> 

See difference between this two metatags: <meta charset="utf-8"> vs <meta http-equiv="Content-Type">

Or you can use header. This code place into your PHP code. The best position is at the start of the document.

header('Content-Type: text/html; charset=utf-8');

Or check if your file is in UTF-8. This you can do with your code editor. I use PSPad and i recommend it to try.

Community
  • 1
  • 1
m1k1o
  • 2,344
  • 16
  • 27
2

In addition to meta headers, the file's own character encoding is also important. I had suffered from the same issue with the files generated with notepad++ and notepad back in Windows, then I saved the file as UTF-8 and it all solved it.

E.g: with Sublime Text; file/save with encoding/UTF-8.

Arda
  • 6,756
  • 3
  • 47
  • 67
  • 1
    Notepad++ shouldn't "create" a problem, unlike Windows Notepad. Notepad++ has different encoding methods. I use Notepad++ with success all the time. – Funk Forty Niner Aug 21 '13 at 13:48
  • @Fred-ii- I don't know, I am the main translator of PHP-Fusion to Turkish, and Notepad++ made me suffer from that exactly issue a couple of years ago (I had to type ascii equivalents of all Turkish characters). I don't know about the current situation though. – Arda Aug 21 '13 at 13:51
  • One of the causes could be if saved with or without BOM. That has made a difference in a lot of cases for me. Someone should have thought about upcoming problems using characters as such, what a pain in the neck it is :( it's a constant battle. – Funk Forty Niner Aug 21 '13 at 13:53
  • You might consider trying out HAPedit 3.1 or Codelobster PHP Edition. I find that they have options that Notepad++ does not have. – Funk Forty Niner Aug 21 '13 at 13:54
  • 1
    @Fred-ii- I was using PHPDesigner after that chaos for a while, but I dropped Windows environment for development totally (and gladly personally!). As a current Linux User, Sublime Text is exactly suits my needs, Thanks though!:) – Arda Aug 21 '13 at 13:57