致命错误:致电未定义的功能mb_substr()
我想看看您对我目前正在遇到的此问题的意见。 事实证明:
<?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).'...';
}
?>
是否以某种方式在网站上给我一个错误,该错误显示:
Fatal error: Call to undefined function mb_substr() in /home/(website)/public_html/index.php on line 308
我不太了解它们的含义mb_substr
,这是PHP版本错误吗? 我目前正在使用PHP 5.3.19
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
mb_substr()
是substr()
,这意味着它可与 targual 一起使用,而不是 bytes < /em>。这在UTF-8中最引人注目,其中许多字符由两个或多个字节表示。根据安装指令,
mbString
不是一个内置扩展。您必须通过拥有适当的文件并正确配置PHP来启用它。可以在提供的链接中找到一些信息,您的网站主机应该能够为您提供帮助。查看是否安装了MBSTRING:
php -m | GREP MBSTRING
for Linux,使用
sudo apt-get安装安装php-mbstring
mb_substr()
is a multibyte-safe version ofsubstr()
, 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.To see if mbstring is installed:
php -m | grep mbstring
For Linux, install using
sudo apt-get install php-mbstring
将其扔进终端:
如果
MBSTRING
显示出来,则应起作用。Throw this into a terminal:
If
mbstring
shows up then it should work.如果您具有root访问权限,则可以使用WHM面板或使用命令行进行配置。我会让您知道如何使用WHM面板进行操作。
1。使用root用户登录到您的WHM
2。转到Easyapache
3。转到以前保存的配置
4。单击基于配置文件的开始自定义。
5。不要更改Apache和PHP版本,只需单击“下一步”。
6。单击PHP配置底部的详尽选择列表
7。选择MBSTRING选项附近的复选框
8。保存和构建
9。如果需要一段时间,请勿关闭浏览器窗口。耐心。
你完成了!!!
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!!!
通过在Red Hat Linux 8中执行以下软件包来解决该问题。
The issue was resolved by executing the following package in Red Hat Linux 8.
错误是告诉您您正在尝试使用一个名为MB_SUBSTR的函数,该功能不存在。
也许您可以使用subttr函数 http://php.net/manual// en/function.substr.php 而不是。 substr(strip_tags($ disc_t),0,10)将返回strip_tags($ disc_t)结果的前十个字符。
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) .