如何解决linux环境下php读取csv文件,出现中文读取不到的情况
如何解决linux环境下php读取csv文件,出现中文读取不到的情况
在做一个数据批量导入的时候出现了一个神奇的问题!
在LIUNX环境下PHP读取csv文件的时候,csv文件中的中文不显示....
在执行csv文件读取前加上一句:
setlocale(LC_ALL, 'zh_CN');
瞬间,问题解决了....
setlocale(LC_ALL, 'zh_CN'); $handle = fopen(”xxx.csv”,”r”); while ($data = fgetcsv($handle, 1000,',')) { ... } fclose($handle);
注解:
// utf-8 setlocale(LC_ALL, 'en_US.UTF-8'); // 简体 setlocale(LC_ALL, 'zh_CN');
扩展相关知识:
以下是常用的地区标识
zh_CN GB2312
en_US.UTF-8 UTF-8
zh_TW BIG5
zh_HK BIG5-HKSCS
zh_TW.EUC-TW EUC-TW
zh_TW.UTF-8 UTF-8
zh_HK.UTF-8 UTF-8
zh_CN.GBK GBK

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
