简体   繁体   English

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

[英]Fatal error: Call to undefined function mb_strlen()

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/

The function mb_strlen() is not enabled by default in PHP. PHP 中默认不启用mb_strlen()函数。 Please read the manual for installation details:请阅读手册以了解安装详细信息:

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

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

sudo apt install php7.0-mbstring

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

sudo apt install php-mbstring

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

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

$ sudo apt-get install php5.6-mbstring

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

PHP 7.2 Ubuntu 18.04

sudo apt install php-mbstring

This question looks to be in relation to PHP on Unix.这个问题看起来与 Unix 上的 PHP 相关。 However, for anyone getting to this question for PHP on Windows, see https://www.php.net/manual/en/install.pecl.windows.php .但是,对于在 Windows 上针对 PHP 解决此问题的任何人,请参阅https://www.php.net/manual/en/install.pecl.windows.php

Since multi-byte string support is a core PHP extension, all that is necessary on Windows is to uncomment this line in your php.ini :由于多字节字符串支持是核心 PHP 扩展,因此在 Windows 上所需要做的就是取消注释php.ini这一行:

extension=php_mbstring.dll

This worked for me on Debian stretch这对我在Debian 伸展上有效

sudo apt-get update
sudo apt install php-mbstring
service apache2 restart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM