摘要:文章提供這款mb_detect_encoding函數(shù)是一款可以檢測你使用的字符串是什么編碼,然后返回字符串編碼字符,下面是一個簡單應(yīng)用實例 functionasciitog($brand){$cha=mb_detect_encoding($brand);if($cha...
轉(zhuǎn)載請注明來源:php 檢測字符編碼mb_detect_encoding()函數(shù)

文章提供這款mb_detect_encoding函數(shù)是一款可以檢測你使用的字符串是什么編碼,然后返回字符串編碼字符,下面是一個簡單應(yīng)用實例.

  1. function asciitog($brand
  2.  $cha=mb_detect_encoding($brand); 
  3.  if($cha=='utf-8'
  4.  { 
  5.    $brand2 = iconv($cha,"gb2312",$brand); 
  6.  } 
  7.  $cha2=mb_detect_encoding($brand2); 
  8.  if($cha2!='ascii'){ 
  9.   $brand=$brand2
  10.  } 
  11.  
  12.  return $brand; //開源代碼phpfensi.com

mb_detect_encoding

語法:string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] )

說明:mb_detect_encoding 用來檢測字符串所使用編碼,并返回相對應(yīng)編碼字符串.

轉(zhuǎn)載請注明來源:php 檢測字符編碼mb_detect_encoding()函數(shù)

  哈爾濱品用軟件有限公司致力于為哈爾濱的中小企業(yè)制作大氣、美觀的優(yōu)秀網(wǎng)站,并且能夠搭建符合百度排名規(guī)范的網(wǎng)站基底,使您的網(wǎng)站無需額外費用,即可穩(wěn)步提升排名至首頁。歡迎體驗最佳的哈爾濱網(wǎng)站建設(shè)。