php

  • The default charset for PHP was changed to UTF-8 in Php 5.6.
  • Stack Overflow works best with JavaScript enabled
  • The default_charset in PHP has been checked and also found to be utf-8.
  • If the data your are trying to display is being fetched from MySQL database, then you should change the charset of the MySQL table and database to UTF-8.
  • It means the default charset for functions that require charset as an argument is UTF-8 by default since PHP 5.6.

I have a site under construction where user posts are displayed. In the development server(on Windows XP) using PHP 5.2.5 and Apache 2.2.6 it is fine,i.e.,special characters are displayed as it is by adding the charset meta tag into the header section of the html page:

@ng_real_ninja: Special Characters not shown accordingly due to possibly improper encoding/decoding on wamp …

I have a site under construction where user posts are displayed. In the development server(on Windows XP) using PHP 5.2.5 and Apache 2.2.6 it is fine,i.e.,special characters are displayed as it is by adding the charset meta tag into the header section of the html page:

And echoing like this:

Then,for example,results are as follows:

Currently,I have uploaded my project into a new development server (on Windows7) with PHP 5.6.29 and Apache 2.4.23 where the same page is displayed as below:

In the new environment, I have also tried with:

But it was fruitless. I also added in the httpd.conf:

The default_charset in PHP has been checked and also found to be utf-8.

But it was all in vein.

I have also checked the character_set_database in MySQL in both the servers(previous and new) which is found to be latin1.

I am pointless as why the same page displayed differently in two versions despite trying myself this little bit. What are the possibilities that lead me to such problems and how will I come out of it with a solution? Thanks in advance!

The default charset for PHP was changed to UTF-8 in Php 5.6. See this link: PHP 5.6 default_charset change may break HTML output.

It means the default charset for functions that require charset as an argument is UTF-8 by default since PHP 5.6. Also PHP sends a content-type header with value UTF-8.

That is probably why your code does not display the same output after you switched to PHP 5.6

If the data your are trying to display is being fetched from MySQL database, then you should change the charset of the MySQL table and database to UTF-8. After that try to reenter the data to the database so it stored with the UTF-8 character encoding.

See also: Php Ini Directives

php