求助phpcms 批量提取內容到描述 亂碼

來源:互聯網
上載者:User
php phpcms 截取 亂碼

PHPCMS 官方論壇人氣不高,特求助CSDN的各位大神們。下面代碼是想要批量提取內容表中的內容到描述欄位中,並過濾字元和截取字數。

但是運行檔案後,資料庫description欄位全是? 代碼如下:


 0xa0 ? $H_start+1 : $H_start);for($i = $H_start; $i < $H_str_len; $i++){if($i >= ($H_start+$H_len)) break;$H_size = ord(substr($H_str, $i, 1)) > 0xa0 ? 3 : 1;$H_tmep .= substr($H_str, $i, $H_size);$i += $H_size > 1 ? 1 : 0;}if(($H_flag == "Y" && $H_start+$H_len < $H_str_len) || $H_flag == "YY"){$H_tmep.="...";}return $H_tmep;}function H_preg_repe($H_str){$H_searh = array ("''si",                   "'<[\/\!]*?[^<>]*?>'si",                            "'([\r\n])[\s]+'",                                  "'&(quot|#34);'i",                                  "'&(amp|#38);'i",                 "'&(lt|#60);'i",                 "'&(gt|#62);'i",                 "'&(nbsp|#160);'i",                 "'&(iexcl|#161);'i",                 "'&(cent|#162);'i",                 "'&(pound|#163);'i",                 "'&(copy|#169);'i",                 "'&#(\d+);'e");                    $H_reple = array ("",                  "",                  "\\1",                  "\"",                  "&",                  "<",                  ">",                  " ",                  chr(161),                  chr(162),                  chr(163),                  chr(169),                  "chr(\\1)");return trim(addslashes(nl2br(stripslashes(preg_replace($H_searh,$H_reple,$H_str)))));}echo "大量新增摘要成功";?>


回複討論(解決方案)

$H_char = 'utf-8'; //這個錯了,mysql 的開發人員最初在書寫代碼時漏寫了一個“-”,導致這個問題一直延續到今天
$H_char = 'utf8';

MySQL 中 utf-8 需寫作 utf8

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.