PHP Error : Trying to get property of non-object

Hello everyone.

I know when this error comes up. But I am surprised, on my development server the same code runs smoothly while on local system, it throws this error.

Can someone please explain, on what criteria this error is thrown?

My scenario:

comments table has userID

there is User table which has userID

in list.php i use it like this

<?php echo CHtml::encode($model->user->Name); ?>

here on local system ‘user’ is null thus this error is thrown.

But then how come on development server it gets executed?

Hmm. Maybe different PHP settings for error_reporting? phpinfo() should help clarify this.

Exactly… correct.

on having "E_ALL | E_STRICT" or "E_ALL & ~E_DEPRECATED" there was still this error

but on making ~E_ALL & ~E_DEPRECATED means error_reporting off, error was not thrown any more.

Thanks a lot. Confusion solved :)