Fatal error: Call to undefined function mb_substr()

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

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) .



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!