第三方接口 - QQ PHP SDK Fatal error: Cannot redeclare class Oauth问题

WBOY
Release: 2016-06-06 20:48:54
Original
1143 people have browsed it

从官网http://wiki.connect.qq.com/sdk%E4%B8%8B%E8%BD%BD# 下载的 PHP SDK
然后install 配置好了之后点击Demo 就出现下面的这个报错,什么代码我都还没改动过。

<code>Fatal error: Cannot redeclare class Oauth in xxx/API/class/Oauth.class.php on line 12 
</code>
Copy after login
Copy after login

是我开发环境的问题吗?Google了很多都未能解决问题。

回复内容:

从官网http://wiki.connect.qq.com/sdk%E4%B8%8B%E8%BD%BD# 下载的 PHP SDK
然后install 配置好了之后点击Demo 就出现下面的这个报错,什么代码我都还没改动过。

<code>Fatal error: Cannot redeclare class Oauth in xxx/API/class/Oauth.class.php on line 12 
</code>
Copy after login
Copy after login

是我开发环境的问题吗?Google了很多都未能解决问题。

这个提示很明确啊,Oauth这个类被重复定义了,这种情况的出现一般是你的项目里面引用了多个第三方的库,在不同的PHP文件里面都定义了class Oauth{ }这样的类,然后在当前执行过程中都被require进来了。解决的话,你可以全局搜索字符串class Oauth找到相关的文件,确保对应的类文件只require一次就行了;或者用class_exists判断包装一下。

还有一种可能,就是服务器安装了oauth php扩展,如果是这样,框架带的OAuth类就可以不要了,二者实现上应该是一样的。

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!