Accent error in PHP x MYSQL, using UTF8_encode() and UTF8_decode()?

时间:2018-12-03 13:12:31

标签: php mysql character-encoding

I am having problems with accentuation in a project that I am giving maintenance.

Table MYQL using utf8_unicode_ci

String Error

$text = 'São Jos�'; #correct São José
echo utf8_decode($text); #print São Jos�
echo utf8_encode($text); #print São Jos�

How to solve using php 5.6?

1 个答案:

答案 0 :(得分:1)

Before you fetch result from the database, fire below query,

SET NAMES UTF8;

This will set the character-set and the results returned will be proper.