PHP: Problems converting “’” character from ISO-8859-1 to UTF-8

后端 未结 2 885
别那么骄傲
别那么骄傲 2021-02-04 20:16

I\'m having some issues with using PHP to convert ISO-8859-1 database content to UTF-8. I am running the following code to test:

// Connect to a latin1 charset d         


        
2条回答
  •  -上瘾入骨i
    2021-02-04 21:01

    this will solve your problem, supposing that your page header charset is utf-8:

    // Opens a connection to a MySQL server
    $connection = mysql_connect ($server, $username, $password);
    $charset = mysql_client_encoding($connection);
    $flagChange = mysql_set_charset('utf8', $connection);
    echo "The character set is: $charset
    mysql_set_charset result:$flagChange
    ";

提交回复
热议问题