php 致命错误:调用未定义的函数 mb_strlen()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6419102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:20:34  来源:igfitidea点击:

Fatal error: Call to undefined function mb_strlen()

phpmysqldatabase

提问by Ali

I'm trying to make a donation center which I use the source code from Totorialzine.

我正在尝试建立一个捐赠中心,我使用来自 Totorialzine 的源代码。

Everything works fine for me at this moment so far but the only problem I was struggling on and trying to look at for the whole day and can't figure what is actually wrong with the code exactly

到目前为止,目前一切对我来说都很好,但唯一的问题是我一直在努力解决并试图查看一整天,但无法弄清楚代码究竟有什么问题

here is what I get when I submit the comment on the page when my visitors donate.

这是我在访问者捐赠时在页面上提交评论时得到的结果。

Fatal error: Call to undefined function mb_strlen() in /home/yoursn0w/public_html/livetv/premium/thankyou.php on line 14

and here is the code in the php file.

这是php文件中的代码。

<?php

require "config.php";
require "connect.php";

if(isset($_POST['submitform']) && isset($_POST['txn_id']))
{
    $_POST['nameField'] = esc($_POST['nameField']);
    $_POST['websiteField'] =  esc($_POST['websiteField']);
    $_POST['messageField'] = esc($_POST['messageField']);

    $error = array();

    if(mb_strlen($_POST['nameField'],"utf-8")<2)
    {
        $error[] = 'Please fill in a valid name.';
    }

    if(mb_strlen($_POST['messageField'],"utf-8")<2)
    {
        $error[] = 'Please fill in a longer message.';
    }

    if(!validateURL($_POST['websiteField']))
    {
        $error[] = 'The URL you entered is invalid.';
    }

    $errorString = '';
    if(count($error))
    {
        $errorString = join('<br />',$error);
    }
    else
    {
        mysql_query("   INSERT INTO dc_comments (transaction_id, name, url, message)
                        VALUES (
                            '".esc($_POST['txn_id'])."',
                            '".$_POST['nameField']."',
                            '".$_POST['websiteField']."',
                            '".$_POST['messageField']."'
                        )");

        if(mysql_affected_rows($link)==1)
        {
            $messageString = '<a href="donate.php">You were added to our donor list! &raquo;</a>';
        }
    }
}

?>

I have my database in the phpMyAdmin uploaded completed

我在 phpMyAdmin 中的数据库上传完成

here is where I follow the instruction of the installation

这是我按照安装说明进行操作的地方

http://tutorialzine.com/2010/05/donation-center-php-mysql-paypal-api/

http://tutorialzine.com/2010/05/donation-center-php-mysql-paypal-api/

回答by AJ.

The function mb_strlen()is not enabled by default in PHP. Please read the manual for installation details:

该功能mb_strlen()在 PHP 中默认不启用。请阅读手册以了解安装详细信息:

http://www.php.net/manual/en/mbstring.installation.php

http://www.php.net/manual/en/mbstring.installation.php

回答by Usman

To fix this install the php7.0-mbstring package:

要解决此问题,请安装 php7.0-mbstring 包:

sudo apt install php7.0-mbstring

回答by webmaster

For me the following command did the trick

对我来说,以下命令可以解决问题

sudo apt install php-mbstring

回答by kubanczyk

On Centos, RedHat, Fedora and other yum-my systems it is much simpler than the PHP manual suggests:

在 Centos、RedHat、Fedora 和其他 yum-my 系统上,它比 PHP 手册建议的要简单得多:

yum install php-mbstring
service httpd restart

回答by Mona Jalal

For me, this worked in Ubuntu 14.04 and for php5.6:

对我来说,这适用于 Ubuntu 14.04 和 php5.6:

$ sudo apt-get install php5.6-mbstring

回答by frmbelz

In case Google search for this error

如果 Google 搜索此错误

Call to undefined function mb_ereg_match()

takes somebody to this thread. Installing php-mbstring resolves it too.

把某人带到这个线程。安装 php-mbstring 也可以解决它。

Ubuntu 18.04.1, PHP 7.2.10

Ubuntu 18.04.1,PHP 7.2.10

sudo apt-get install php7.2-mbstring

回答by M_R_K

PHP 7.2 Ubuntu 18.04

PHP 7.2 Ubuntu 18.04

sudo apt install php-mbstring