如何修复对非对象的成员函数的调用 [英] How to fix Call to a member function on a non-object

查看:92
本文介绍了如何修复对非对象的成员函数的调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个登录/注册系统,我收到了这个错误

致命错误:在D:\ ProgramFile \ Xampp中的非对象上调用成员函数passed()第28行\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ > http://pastebin.com/RLPAKUEA [ ^ ]

http://pastebin.com/2HU4yLVu [ ^ ]



提前谢谢。

PS对不起,如果我是菜鸟,我对OOP / PDO很新。

I'm creating a login/register system and I got this error
Fatal error: Call to a member function passed() on a non-object in D:\ProgramFile\Xampp\htdocs\site\shop\register.php on line 28
my code is
http://pastebin.com/RLPAKUEA[^]
http://pastebin.com/2HU4yLVu[^]

Thank you in advance.
P.S. Sorry if I'm noob I'm very new to OOP/PDO.

推荐答案

您发布的代码似乎没有任何问题。该错误意味着可能隐藏在类配置中的其他地方,因为这是您调用时唯一会运行的代码 - >传递()。

There seem not to be anything wrong with the codes you posted. The bug meant be hidden somewhere else probably in your class config, because this is the only code that will run when you call ->passed().
private function __construct(){
        try {


this- > _pdo = new PDO(
' mysql:host =' .config :: get(' mysql / host'), // 获取主机名
' dbname =' .config :: get(' mysql / db'), // 获取数据库名称
config :: get(' mysql / u sername'),
config :: get(' mysql / password' ));
} catch (PDOException
this->_pdo = new PDO( 'mysql:host=' . config::get('mysql/host'),//get host name 'dbname=' . config::get('mysql/db'),//get database name config::get('mysql/username'), config::get('mysql/password')); } catch (PDOException


e){
die(
e){ die(


这篇关于如何修复对非对象的成员函数的调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆