WordPress 提示Fatal error: Call to undefined function mb_strimwidth()

來源:互聯網
上載者:User

解決方案如下:

開啟php.ini,找到;

 代碼如下 複製代碼
extension=php_mbstring.dll,


去掉前面的分號儲存,重啟IIS或PHP即可。

如果上面方法不能解決可參考

在Google了一陣後終於找到了一個完美的解決方案。

本來沒有mb_strimwidth函數開啟wordpress首頁時是肯定會出現
Fatal error: Call to undefined function: mb_strimwidth() 錯誤在index.php第17行
這樣的提示的,然後開啟正在使用的wordpress模板的index.php後第17行會發現如下一段

 代碼如下 複製代碼

<?php

echo dm_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 290,"..."); ?>

將其更改為:

 代碼如下 複製代碼

<?php

echo ok_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 290,"...");

?>

那麼 ok_strimwidth這個函數在這裡是調用了,可是存在哪呢?別著急,開啟wordpress的 wp-includes目錄會有一個functions.php,
在裡面增加如下代碼

 代碼如下 複製代碼

functionok_strimwidth($str ,$start , $width ,$trimmarker ){
 $output = preg_replace('/^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,'.$start.'}((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,'.$width.'}).*/s','1',$str);
 return $output.$trimmarker;
}

這樣就定義了 ok_strimwidth函數,現在開啟你的首頁看看是不是正常了?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.