Home > Backend Development > PHP Problem > What should I do if PHP uses UTF8 encoding to read the garbled ACCESS code?

What should I do if PHP uses UTF8 encoding to read the garbled ACCESS code?

coldplay.xixi
Release: 2023-03-04 08:28:02
Original
2511 people have browsed it

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.

What should I do if PHP uses UTF8 encoding to read the garbled ACCESS code?

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);}
Copy after login

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);}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template