久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動(dòng):電腦PC端+手機(jī)端+微網(wǎng)站+自適應(yīng)網(wǎng)頁(yè)多模板選擇-建站388元起價(jià)!!!
當(dāng)前位置:主頁(yè) > 網(wǎng)站建設(shè) > dedecms重新定義cn_substr函數(shù)截取字?jǐn)?shù)更精準(zhǔn),織夢(mèng)文

dedecms重新定義cn_substr函數(shù)截取字?jǐn)?shù)更精準(zhǔn),織夢(mèng)文

時(shí)間:2023-07-21 11:07:21 閱讀: 文章分類: 網(wǎng)站建設(shè) 作者: 織夢(mèng)網(wǎng)站員

導(dǎo)讀:織夢(mèng)文章織夢(mèng)文章,dedecms的cn_substr()和cn_substr_utf8()截取的字符串ms不準(zhǔn),平時(shí)也用習(xí)慣cn_substr(),也不愿用什么cn_subst織夢(mèng)模板免費(fèi)下裁織夢(mèng)模板。

織夢(mèng)模板免費(fèi)下裁織夢(mèng)模板

,dedecms的cn_substr()和cn_substr_utf8()截取的字符串ms不準(zhǔn),平時(shí)也用習(xí)慣cn_substr(),也不愿用什么cn_substr_utf8()今天弄了下,現(xiàn)在還是比較準(zhǔn)了。按照一個(gè)漢字2個(gè)字節(jié)調(diào)用就行了!

方法說(shuō)明: 一、找到\include\helpers\string.helper.php把原來(lái)約33到102行(也就是定義cn_substr()函數(shù)的那段代碼)替換掉,你要是怕不行,可以先把這個(gè)文件備份下,親;

  • /**
  • *中英文截取字符串,漢字安2個(gè)字節(jié)
  • *
  • * @accesspublic
  • * @param string$str 需要截取的字符串
  • * @param int$cutLen 截取的長(zhǎng)度
  • * @param bool $cutSlashes 是否去掉\
  • * @param bool $addSlashes 是加\
  • * @param string $oDot 截取后加的字符串,如經(jīng)常用的三個(gè)點(diǎn)
  • * @param bool $hasHtml 是否有html
  • * @returnstring
  • */
  • if ( ! function_exists(‘cn_substr’)){
  • function cn_substr($str, $cutLen, $oDot = null, $hasHtml = false, $cutSlashes = false, $addSlashes = false) {
  • global $cfg_soft_lang;
  • $str = trim ( $str );
  • if ($cutSlashes) $str = stripslashes ( $str );
  • if($hasHtml){
  • $str = preg_replace ( “/(\<[^\<]*\>|\r|\n|\s|\[.+?\])/is”, ‘ ‘, $str );
  • $str = htmlspecialchars ( $str );
  • }else{
  • $str = htmlspecialchars ( $str );
  • }
  • if ($cutLen && strlen ( $str ) > $cutLen) {
  • $nStr = ̶織夢(mèng)cms模板1;;
  • if ($cfg_soft_lang == ‘utf-8′) {
  • $n = 0;
  • $tn = 0;
  • $noc = 0;
  • while ( $n < strlen ( $str ) ) {
  • $t = ord ( $str [$n] );
  • if ($t == 9 || $t == 10 || (32 <= $t &&a手機(jī)模板dedemp; $t <= 126)) {
  • $tn = 1;
  • $n ++;
  • $noc ++;
  • } elseif (194 <= $t && $t <= 223) {
  • $tn = 2;
  • $n += 2;
  • $no織夢(mèng)模板免費(fèi)c += 2;
  • } elseif (224 <= $t && $t < 239) {
  • $tn = 3;
  • $n += 3;
  • $noc += 2;
  • } elseif (240 <= $t && $t <= 247) {
  • $tn = 4;
  • $n += 4;
  • $noc += 2;
  • } elseif (248 <= $t && $t <= 251) {
  • $tn = 5;
  • $n += 5;
  • $noc += 2;
  • } elseif ($t == 252 || $t == 253) {
  • $tn = 6;
  • $n += 6;
  • $noc += 2;
  • } else {
  • $n ++;
  • }
  • if ($noc >= $cutLen)break;
  • }
  • if ($noc > $cutLen) $n -= $tn;
  • $nStr = substr ( $str, 0, $n );
  • } else {
  • for($i = 0; $i < $cutLen – 1; $i ++) {
  • if (ord ( $str [$i] ) > 127) {

    關(guān)鍵詞標(biāo)簽: 精準(zhǔn) 函數(shù) 織夢(mèng)

  • 聲明: 本文由我的SEOUC技術(shù)文章主頁(yè)發(fā)布于:2023-07-21 ,文章dedecms重新定義cn_substr函數(shù)截取字?jǐn)?shù)更精準(zhǔn),織夢(mèng)文主要講述精準(zhǔn),函數(shù),織夢(mèng)網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請(qǐng)保留鏈接: http://www.bifwcx.com/article/web_33481.html

    我的IDC 網(wǎng)站建設(shè)技術(shù)SEOUC.COM
    專注網(wǎng)站建設(shè),SEO優(yōu)化,小程序設(shè)計(jì)制作搭建開(kāi)發(fā)定制網(wǎng)站等,數(shù)千家網(wǎng)站定制開(kāi)發(fā)案例,網(wǎng)站推廣技術(shù)服務(wù)。
  • 5000+合作客服
  • 8年從業(yè)經(jīng)驗(yàn)
  • 150+覆蓋行業(yè)
  • 最新熱門源碼技術(shù)文章

    主站蜘蛛池模板: 喀喇| 汉沽区| 桐梓县| 昌江| 波密县| 永昌县| 江华| 施甸县| 贺州市| 海丰县| 盐边县| 凤山县| 安阳县| 蒙城县| 曲周县| 蒙自县| 曲阜市| 土默特左旗| 乐亭县| 临猗县| 蕲春县| 北票市| 定安县| 元朗区| 东丰县| 册亨县| 高阳县| 繁昌县| 苍梧县| 天峻县| 安新县| 灵寿县| 澳门| 昌黎县| 潜江市| 濮阳县| 苍山县| 武城县| 定陶县| 安平县| 石柱|