PHP htmlentities() 函数
之前运用到了一个PHP导出EXCEL的类,里面有一段代码用来过滤字符串里的引号。用到了htmlentities() 函数,后来导出EXCEL的时候又一个字无法导出,感觉很奇怪,所有字都行就只有这个字不行,后来翻查了一下这个函数的相关资料。
定义和用法htmlentities() 函数把字符转换为 HTML 实体。
htmlentities(string,quotestyle,character-set)
string | 必需。规定要转换的字符串。 |
quotestyle | 可选。规定如何编码单引号和双引号。 ENT_COMPAT - 默认。仅编码双引号。 ENT_QUOTES - 编码双引号和单引号。 ENT_NOQUOTES - 不编码任何引号。 |
character-set | 可选。字符串值,规定要使用的字符集。 ISO-8859-1 - 默认。西欧。 ISO-8859-15 - 西欧(增加 Euro 符号以及法语、芬兰语字母)。 UTF-8 - ASCII 兼容多字节 8 比特 Unicode cp866 - DOS 专用 Cyrillic 字符集 cp1251 - Windows 专用 Cyrillic 字符集 cp1252 - Windows 专用西欧字符集 KOI8-R - 俄语 GB2312 - 简体中文,国家标准字符集 BIG5 - 繁体中文 BIG5-HKSCS - Big5 香港扩展 Shift_JIS - 日语 EUC-JP - 日语 |
原来character-set设置GB2312字符集,无法导出的那个文字是“?”,后来翻查一下,GB2312字符集里面根本就没有“?”字,所以导出来的EXCEL里,含有该字的单元格都为空。
解决方法,character-set设置为UTF-8字符集,这样的话,需要把导出EXCEL的数组也转化成UTF-8字符集。
遇到问题,不要害怕,想办法去解决才是王道。

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

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



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
