Home > Backend Development > PHP Tutorial > 底下这句话何解

底下这句话何解

WBOY
Release: 2016-06-13 12:20:12
Original
967 people have browsed it

下面这句话何解

本帖最后由 tp_2016 于 2015-05-19 20:06:10 编辑 if (strtoupper(CHARSET) == 'GBK' && !empty($key)){
if (is_array($key)){
$result = var_export($key, true);//变为字符串
$result = iconv('UTF-8','GBK',$result);
eval("\$result = $result;");//转换回数组
}else {
$result = iconv('UTF-8','GBK',$key);
}
}
return $result;

这句中的CHARSET是啥意思,不可思议,是实随便一个字符串试探吗
还有eval("\$result = $result;");为啥能转成数组呢
------解决思路----------------------
CHARSET 是个常量
eval() 函数把字符串按照 PHP 代码来计算。去看看手册中该函数的介绍就明白了。
------解决思路----------------------
CHARSET 是个常量,可以找找 define('CHARSET', xxx); 定义。
eval就是把字符串转为代码执行。
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template