Spanish Characters not Displaying Correctly

后端 未结 7 2119
心在旅途
心在旅途 2021-02-08 12:24

I am getting the lovely � box where spanish characters should be displayed. (ie: ñ, á, etc). I have already made sure that my meta http-equiv is set to utf-8:

&         


        
7条回答
  •  天命终不由人
    2021-02-08 13:10

    Things to consider in PHP/MySQL/UTF-8

    • The database tables and text columns should be set to UTF-8
    • HTML page Content-Type should be set to UTF-8

    • PHP should send a header informing the browser to expect UTF-8

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

    • The PHP-MySQL connection should be set to UTF-8

      mysqli_query("SET CHARACTER_SET_CLIENT='utf8'",$conn);

      mysqli_query("SET CHARACTER_SET_RESULTS='utf8'",$conn);

      mysqli_query("SET CHARACTER_SET_CONNECTION='utf8'",$conn);

    • PHP ini has default_charset setting it should be utf-8 if you do not have access to it use ini_set('default_charset', 'utf-8');

提交回复
热议问题