PHP无法访问受保护的属性错误 [英] PHP cannot access protected property error

查看:158
本文介绍了PHP无法访问受保护的属性错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP致命错误:无法访问受保护的属性Exception :: $ message在/web/index.php的第23行

PHP Fatal error: Cannot access protected property Exception::$message in /web/index.php on line 23

我在第23行,

echo '<?xml version=\'1.0\'?><error-response status="error">
<message><![CDATA['.$e->message.']]></message>
</error-response>';

我看不到有什么问题,但是偶尔在日志中看到上述异常.怎么了?

I can't see anything wrong with this, but I see the above exception occasionally in the logs. What's wrong?

推荐答案

使用$e->getMessage()代替$e->message,因为消息是受保护的属性:)

Use $e->getMessage() instead of $e->message because message is a protected property :)

这篇关于PHP无法访问受保护的属性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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