PHP试图让非对象的属性 [英] PHP Trying to get property of non-object

查看:692
本文介绍了PHP试图让非对象的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行APNS PHP脚本,它的工作正常,但一个文件抛出PHP错误,我想知道我应该怎么解决它。

I'm running an APNS PHP script and it's working fine but one file throws PHP errors and I want to know how I should fix it.

下面的错误弹出:

/usr/bin/php -f /usr/share/nginx/www/processFeedback.php

<br/>Started processing FeedbackPHP Notice:  Trying to get property of non-object in /usr/share/nginx/www/processFeedback.php on line 46
PHP Warning:  stream_socket_client(): unable to connect to  (Failed to parse address "") in /usr/share/nginx/www/classes/Apns.php on line 66
PHP Notice:  Undefined variable: errstrn in /usr/share/nginx/www/classes/Apns.php on line 69
PHP Fatal error:  Uncaught exception 'Exception' with message '<br/>Failed to connect 0 ' in /usr/share/nginx/www/classes/Apns.php:69
Stack trace:
#0 /usr/share/nginx/www/classes/Apns.php(49): Apns->connect()
#1 /usr/share/nginx/www/processFeedback.php(46): Apns->__construct(NULL, 'certificates/ck...', 'passwd')
#2 {main}
  thrown in /usr/share/nginx/www/classes/Apns.php on line 69

46号线:

$apns = new apns($server->ServerUrl, $certificatePath, $certificate->Passphrase);

66号线:

$this->stream = stream_socket_client($this->server, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);

69号线:

throw new Exception("<br/>Failed to connect $err $errstrn");

PHP文件:<一href=\"https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/processFeedback.php\" rel=\"nofollow\">https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/processFeedback.php

DataService.php:<一href=\"https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/DataService.php\" rel=\"nofollow\">https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/DataService.php

DataService.php: https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/DataService.php

APNS.php:<一href=\"https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/Apns.php\" rel=\"nofollow\">https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/Apns.php

我不是一个PHP的专家,所以我错过了什么?

I'm not a PHP expert so what am I missing?

推荐答案

就在堆栈跟踪看准了这一点:

Just spotted this in the stack trace:

#1 /usr/share/nginx/www/processFeedback.php(46): Apns->__construct(NULL, 'certificates/ck...', 'passwd') .

这清楚地表明,$服务器是NULL。你有什么期望SERVERURL是?也许你可以只在相关的行输入一个字符串,像这样:

This clearly shows that $server is NULL. What do you expect the ServerUrl to be? Maybe you could just enter that as a string in the line in question, like so:

$apns = new apns('myServerUrl', $certificatePath, $certificate->Passphrase)

这篇关于PHP试图让非对象的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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