function is_utf8($s) {
return preg_match('/^(?:[\x00-\x7f]|[\xc0-\xff][\x80-\xbf]+)+$/', $s);
}
如果是ie 搜索时地址栏带有中文时,php编码为utf-8 时,接受到的参数会显示乱码,通过上面的方法可以判断出来是不是 utf-8 编码。
如果不是 则用php转码函数 iconv('GBK', 'UTF-8', $s);
以上方法摘自: <a target=_blank href="http://bbs.youkuaiyun.com/topics/120076474#post-111899419">点击打开链接</a>