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

下面这句话何解

WBOY
Release: 2016-06-23 13:34:23
Original
1002 people have browsed it

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