WordPress 提示Fatal error: Call to undefined function mb_strimwidth() in category.php on line 27,原因PHP沒有啟用mb_strimwidth函數.
解決方法如下:
打開php.ini,找到如下代碼:
extension=php_mbstring.dll,
去掉前面的分號保存,重啟IIS或PHP即可。
如果上面方法不能解決可參考,在谷歌了一陣后終于找到了一個完美的解決方案,本來沒有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,"...");//開源軟件:Vevb.com
- ?>
那么 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函數,現在打開你的首頁看看是不是正常了?
新聞熱點
疑難解答
圖片精選