可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I wanted to see your input on this concern I'm currently experiencing. It turns out that:
<?php $disc_t=$name; if(strlen($disc_t)<=15) { $name_now=mb_substr( strip_tags($disc_t), 0, 10 ).''; } else { $name_now=mb_substr( strip_tags($disc_t), 0, 10).'...'; } ?>
is somehow giving me an error on the site, the error shows:
Fatal error: Call to undefined function mb_substr() in /home/(website)/public_html/index.php on line 308
I don't quite understand what they mean by mb_substr
, is this a PHP version error? I am currently using PHP 5.3.19
回答1:
Throw this into a terminal:
php -m | grep mb
If mbstring
shows up then it should work.
回答2:
mb_substr()
is a multibyte-safe version of substr()
, meaning it works with characters as opposed to bytes. This is most noticeable in UTF-8, where many characters are represented by two or more bytes.
According to the installation instructions, mbstring
is not a built-in extension. You must enable it by having the appropriate files and configuring PHP correctly. Some information can be found in the link provided, your webhost should be able to help you with the rest.
For Linux, install using
sudo apt-get install php7.0-mbstring
回答3:
If you have root access, you can configure it using WHM Panel or using Command Line. I will let you know how you can do it using WHM Panel.
1. Login to your WHM with Root User
2. Go to Easyapache
3. Go to previously saved configuration
4. Click on Start Customizing based on Profile.
5. Don't change apache and php version, just click next.
6. Click on Exhaustive options list at the bottom of php configuration
7. Select the checkbox near MBString option
8. Save and Build
9. Do not close your browser window if it takes a while. Be patient.
You are Done!!!
回答4:
The error is telling you that you are trying to use a function named mb_substr that doesn't exist.
Perhaps you can achieve the same result using the substr function http://php.net/manual/en/function.substr.php instead. substr(strip_tags($disc_t), 0, 10) will return the first ten characters of the result of strip_tags($disc_t) .