Home > Backend Development > PHP Tutorial > Class 'MongoClient' not found

Class 'MongoClient' not found

WBOY
Release: 2016-06-06 20:09:29
Original
1620 people have browsed it

环境:
PHP5.6.2
Apache2

安装php-mongo driver

<code>[Jack:~ $] sudo pecl install mongo
pecl/mongo is already installed and is the same as the released version 1.6.14

[Jack:~ $] vi /etc/php.ini
extension=mongo.so

[Jack:~ $] apachectl restart
</code>
Copy after login
Copy after login

我已经安装php-mongo driver,php.ini也添加了扩展,但是还是报这个错,怎么破?
代码:

<code><?php error_reporting(E_ALL);
ini_set('display_errors', 1);
$mongo = new MongoClient();
</code></code>
Copy after login
Copy after login

报错:

<code>Fatal error: Class 'MongoClient' not found in /private/var/www/index.php on line 5</code>
Copy after login
Copy after login

回复内容:

环境:
PHP5.6.2
Apache2

安装php-mongo driver

<code>[Jack:~ $] sudo pecl install mongo
pecl/mongo is already installed and is the same as the released version 1.6.14

[Jack:~ $] vi /etc/php.ini
extension=mongo.so

[Jack:~ $] apachectl restart
</code>
Copy after login
Copy after login

我已经安装php-mongo driver,php.ini也添加了扩展,但是还是报这个错,怎么破?
代码:

<code><?php error_reporting(E_ALL);
ini_set('display_errors', 1);
$mongo = new MongoClient();
</code></code>
Copy after login
Copy after login

报错:

<code>Fatal error: Class 'MongoClient' not found in /private/var/www/index.php on line 5</code>
Copy after login
Copy after login

命令行执行php -m检查一下模块是否加载

你写错了,应该是new mongo

安装扩展你可以参考这个,基本一样的扩展

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template