作者:ANNIE炫可_315 | 来源:互联网 | 2023-05-17 18:54
Ihaveasimilartoissuetothatdescribedhere:我有类似于此处描述的问题:EverythingworksasIwouldexpect;
I have a similar to issue to that described here:
我有类似于此处描述的问题:
Everything works as I would expect; my code accesses the database and prints output irrespective of whether I run in from my command line interface or from the web browser. Same result. If I run it in Eclipse with PHPUnit, I get an error:
一切都按照我的预期运作;我的代码访问数据库并打印输出,无论我是从命令行界面还是从Web浏览器运行。结果相同。如果我使用PHPUnit在Eclipse中运行它,我会收到一个错误:
Multiple annotations found at this line:
- Fatal error: Class 'mysqli' not found
- Occurrence of 'connection'
Which points at the following line:
哪个指向以下行:
This code prints out 'Yes'.
此代码打印出“是”。
$cOnnection= new \mysqli(HOST, USER, PASS, DATABASE);
if (extension_loaded('mysqli')) {
echo "Yes";
}
else {
echo "No";
}
One more thing to point out is that I'm using my own namespace in the class where the above code is located. My unit tests are in the global namespace.
还有一点需要指出的是,我在上面代码所在的类中使用了自己的命名空间。我的单元测试在全局命名空间中。
I've followed the steps in the URL above but, alas, to no avail. :(
我已经按照上面的URL中的步骤进行了操作,但是,唉,无济于事。 :(
Running this on the command prompt gives no errors:
在命令提示符下运行此命令不会出现错误:
php -r "new mysqli();"
Please could someone help me understand the issue here?
请有人帮我理解这个问题吗?
1 个解决方案