Press "Enter" to skip to content

Fatal error: Class 'MySQLi' not found的解决方法之一

在使用mysqli函数库时有可能会遇到该问题,我来说一下在我的电脑(ubuntu17.01,PHP7.1)上我的问题的解决办法。

首先运行含有此段代码的PHP脚本:

<?php
if(!function_exists('mysqli_init')&&!extension_loaded('mysqli')){
    echo 'We don\'t have mysqli!!!';
} else {
    echo 'Phew we have it!';
}
?>

如果显示没有mysqli,就进行安装:

sudo apt-get install php-mysqlnd

然后重启apache服务器:

/etc/init.d/apache2 restart

One Comment

  1. 先生 先生 2018年3月11日

    受用了!多谢

发表评论

电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax