您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php怎么查询变量的编码

2025/12/13 21:27:34发布32次查看
在php中可以通过mb_detect_encoding函数查询变量的编码,该函数的作用就是检测字符的编码,其使用语法是“mb_detect_encoding(string $str, mixed $encoding_list...)”。
本文操作环境:windows7系统、php7.1版、dell g3电脑
php怎么查询变量的编码?
mb_detect_encoding
(php 4 >= 4.0.6, php 5, php 7, php 8)
mb_detect_encoding — 检测字符的编码
说明 
mb_detect_encoding(string $str, mixed $encoding_list = mb_detect_order(), bool $strict = false): string
检测字符串 str 的编码。
参数
str
待检查的字符串。
encoding_list
encoding_list 是一个字符编码列表。 编码顺序可以由数组或者逗号分隔的列表字符串指定。
如果省略了 encoding_list 将会使用 detect_order。
strict
strict 指定了是否严格地检测编码。 默认是 false。
返回值
检测到的字符编码,或者无法检测指定字符串的编码时返回 false。
范例
示例 #1 mb_detect_encoding() 例子
<?php/* 使用当前的 detect_order 来检测字符编码 */echo mb_detect_encoding($str);/* "auto" 将根据 mbstring.language 来扩展 */echo mb_detect_encoding($str, "auto");/* 通过逗号分隔的列表来指定编码列表 encoding_list */echo mb_detect_encoding($str, "jis, eucjp-win, sjis-win");/* 使用数组来指定编码列表 encoding_list */$ary[] = "ascii";$ary[] = "jis";$ary[] = "euc-jp";echo mb_detect_encoding($str, $ary);?>
参见 
mb_detect_order() - 设置/获取 字符编码的检测顺序
推荐学习:《php视频教程》
以上就是php怎么查询变量的编码的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product