Solution to PHP using UTF8 encoding to read ACCESS garbled characters: First use the iconv function to make a transcoding custom function from GBK to [UTF-8]; then make a function from [UTF-8] Turn to the GBK function; finally use the [dec()] function when submitting data from the page to the database.
Solution to PHP using UTF8 encoding to read ACCESS garbled characters:
1. Use the iconv function to create a conversion Code customization function to convert from GBK to UTF-8, such as the following code:
function enc($c){return iconv('gbk','utf-8',$c);}
2. In order to write the encoding to the database to meet the needs of the database, we also need to make a conversion from UTF-8 GBK function:
function dec($c){return iconv('utf-8','gb2312',$c);}
After making the transcoding function, you can use it normally. Use the enc()
function when transferring data from the database to display on the page, and use the dec()
function when submitting data from the page to the database. This can be a good solution to PHP Using UTF-8
encoding, ACCESS uses the system default encoding.
Related learning recommendations: php programming (video), access database Tutorial
The above is the detailed content of What should I do if PHP uses UTF8 encoding to read the garbled ACCESS code?. For more information, please follow other related articles on the PHP Chinese website!