Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP cannot access protected property error

Tags:

php

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

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

On line 23 I have,

echo '<?xml version=\'1.0\'?><error-response status="error"> <message><![CDATA['.$e->message.']]></message> </error-response>'; 
like image 457
Ram Avatar asked Jun 10 '11 13:06

Ram


1 Answers

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

like image 117
Karl-Bjørnar Øie Avatar answered Oct 04 '22 16:10

Karl-Bjørnar Øie