Question 1:
When writing code on Windows, the test encountered a garbled code problem.
Method one:
Use the function mb_convert_encoding() and make the following settings:
$str = mb_convert_encoding($str, "UTF-8", "GBK");
Method two:
Use the function iconv() and make the following settings:
iconv(‘GBK',”UTF-8//TRANSLIT//IGNORE”,$str);
These two functions are used to solve the problem of garbled characters on Windows.
Question 2: When
was submitted to the Linux system, garbled characters occurred again.
php reads csv files, but Chinese cannot be read on Linux. Solution:
Add a line of code:
setlocale(LC_ALL, 'zh_CN');
PHP setlocale( ) Function explanation:
setlocale() function sets regional information (regional information).
Regional information is language, currency, time and other information for a geographical area. This function returns the current locale, or false on failure.
Recommended tutorial: PHP video tutorial
The above is the detailed content of Garbled characters appear in the php import file. 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

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

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
