PHP 5.6 update makes UTF-8 unworkable

I recently updated my PHP-Webspace to 5.6 (from 5.5) and something strange happened. My site is unexpectedly displaying UTF-8 characters incorrectly even though I'm using Meta Tag <meta charset="utf-8">

and the following line in my .htaccess file AddDefaultCharset utf-8

.

After entering the next line in my PHP-Script, everything worked again header('Content-Type: charset=utf-8');

.

This was happening on my web space (where I don't have access to php.ini file) and local server. Since I also use other PHP scripts, I don't want to embed header('Content-Type: charset=utf-8');

in all config files ...

What could be the reason?

+3


source to share


2 answers


If you don't want to use the header () php function, you can use the tag meta

for html.

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

      



Please check if this helps.

0


source


As I read:

the default_charset php.ini parameter changed in PHP 5.6 from empty to UTF-8. This can break the HTML output if you try to set a different encoding in your HTML head. It can also break down functions like htmlentities () and htmlspecialchars.



src: https://www.saotn.org/php-56-default_charset-change-may-break-html-output/

In my case, I used the default UTF-8 character set using the php function mb_http_output('UTF-8');

, although for PHP5.6 I removed this function as it seemed redundant. This made the symbols appear again.

0


source







All Articles