欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php 判斷網(wǎng)頁是否是utf8編碼的方法

 更新時間:2014年06月06日 01:23:35   作者:  
這篇文章主要介紹了php 判斷網(wǎng)頁是否是utf8編碼的方法,需要的朋友可以參考下
//判斷編碼
復(fù)制代碼 代碼如下:

$encode = mb_detect_encoding($q, array('GB2312','GBK','UTF-8'));
echo $encode."<br/>";
if($encode=="GB2312")
{
    $q = iconv("GBK","UTF-8",$q);
}
else if($encode=="GBK")
{
    $q = iconv("GBK","UTF-8",$q);
}
else if($encode=="EUC-CN")
{
    $q = iconv("GBK","UTF-8",$q);
}
else//CP936
{
    //$q = iconv("GB2312","UTF-8",$q);
}


其實就是利用了mb_detect_encoding函數(shù),如果不是utf8編碼就轉(zhuǎn)換為utf8編碼,防止出現(xiàn)亂碼等情況。

相關(guān)文章

最新評論