欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          解決php中文亂碼轉換問題

          php中文亂碼轉換的解決辦法:1、設置編碼為“header('Content-Type:text/html;charset=utf-8');”;2、使用“mb_convert_encoding”等函數(shù)進行轉換。

          解決php中文亂碼轉換問題

          推薦:《PHP視頻教程》

          PHP代碼中文輸出亂碼和轉碼問題

          1.header('Content-Type:text/html;charset=utf-8'); 防止json格式的中文亂碼輸出,在輸出之前寫出此代碼行

          2.字符轉碼:$a為待轉碼字符串,$encode為 $a的編碼規(guī)則,$to_encode 為$a 將要轉的編碼規(guī)則,$str_encode 轉碼后的字符串,

          (一): $encode = mb_detect_encoding($a, array("ASCII", 'UTF-8', "GB2312", "GBK", 'BIG5'));//獲取當前字符串的編碼 $str_encode = mb_convert_encoding($a, $to_encode, $encode);//將字符編碼改為$to_encode (二):$str_encode = iconv($encode, $to_encode, $a);//例:$A = iconv("gbk", "utf-8", $A); (三):/**  * 1.自動識別編碼并轉換為UTF-8  */ function characet($data){   if( !empty($data) ){        $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;       if( $fileType != 'UTF-8'){         $data = mb_convert_encoding($data ,'utf-8' , $fileType);       }     }     return $data;    }

          3.自己寫了一個小得處理PHP代碼http調試時輸出漢字的代碼:

          //防止中文轉碼,遍歷數(shù)據(jù)結果,每項單獨urlencode,     public function arrayUrlencode($array) {         if (empty($array)) {             return $array;         } else {             foreach ($array as $key =>$value) {//對每個數(shù)組元素進行urlencode                 if (is_array($value)) {                     $array[$key] =$this->arrayUrlencode($value);                 } else {                     $array[$key] =urlencode($value);                 }             }         }         return $array;     }       //再整體urldecode     public function arrayJsonencode($array) {         $url_arr =$this->arrayUrlencode($array);         $json_arr = json_encode($url_arr);//json 輸出         return urldecode($json_arr); //整體urldecode }

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號