Solution to php access garbled code: 1. Use iconv function to create a transcoding custom function from GBK to "UTF-8"; 2. Create a transcoding function from "UTF-8" to GBK Function, the statement is "dec($c){return iconv(...)).
PHP Video Tutorial 》
Solution to the garbled problem of PHP using UTF8 encoding to read ACCESS
PHP paired with ACCESS is a very cold topic, but it has a lot of practicality, especially Programmers who have transferred from ASP have a special understanding of ACCESS. Xuewen Training will also talk about the system development of ACCESS with PHP in actual PHP training. So today we will share what PHP ACCESS usually does in actual development. Solution to the UTF-8 encoding problem encountered. How does the garbled problem occur when PHP uses UTF8 encoding to read the ACCESS database?First of all, PHP is an international programming language. We usually use UTF-8 encoding when using it. If it is used with a MYSQL database and is set to UTF-8 encoding in the MYSQL database, there will be no problems when reading. Secondly, ACCESS is a A small local database developed by Microsoft, which uses the local system encoding by default. The Simplified Chinese system uses GBK encoding. And this encoding type cannot be changed. So the problem arises!! UTF-8 PHP reads GBK's ACCESS, and garbled characters will appear when the data is displayed on the page. Of course, don't worry if you encounter this problem, it will not damage the database when the data is not written. Data. The next step is how to solve this problem. The solution is as follows: 1. Use the iconv function to make a custom transcoding function 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 function to convert from UTF-8 to GBK:
function dec($c){return iconv('utf-8','gb2312',$c);}After making the transcoding function, the next step is normal Used. 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 solve the problem of PHP using UTF-8 encoding and ACCESS using the system. There is a problem with the default encoding.
The above is the detailed content of How to solve the garbled problem of php access. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools
