php 数组键名 能是中文, 哪位高手用过,会不会出现后患.
Jun 13, 2016 am 11:10 AM
gbk
hash
key
nbsp
php
php 数组键名 能是中文, 谁用过,会不会出现后患...
RT 中文键名会不会留下后患>
------解决方案--------------------
可以用,没有问题
------解决方案--------------------
php的数组键名会被php内部转换为一个hash key。理论上没有问题。但中文总是会引起很多奇怪的bug。比如gbk下的低字节5c问题。
还有不同字符集下,php内部识别的unicode会不一致。我猜想,但没有实践过:
假如你的a.php使用了gbk编码,代码中声明了一个$a['中文']='123'的中文key数组。
b.php引用了a.php。但b.php文件本身的编码是utf-8。然后在b.php中echo $a['中文']。
此时,两个文件中的'中文'俩字在php内部所转换的hash key可能是不一致的,那么会造成b.php中的$a['中文']取不到任何值。
所以最好不要用中文。
------解决方案--------------------
呵呵,有一种扰码工具恰恰就是利用了这一点,让你无法破解
------解决方案--------------------
试一下这几个字(限GBK):榎 梶 東
如果这几个字没问题就全部没问题了……

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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

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

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

Unpatchable Yubico two-factor authentication key vulnerability breaks the security of most Yubikey 5, Security Key, and YubiHSM 2FA devices
