This question already has answers here:
UTF-8 all the way through
                                
                                    (15个答案)
                                
                        
                                2年前关闭。
            
                    
我在进行维护的项目中遇到强调问题。


  
    使用utf8_unicode_ci的表MYQL
  


字符串错误

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


如何使用php 5.6解决?

最佳答案

在您从数据库中获取结果之前,请在查询下方进行操作,

SET NAMES UTF8;


这将设置字符集,并且返回的结果将是正确的。

10-04 17:14