how to handle PHP Notice ?

my "Project" list view code. A Project can have a country or no country. Country field is optional


    'attribute' => 'country_id',

    'label' => 'Country',

    'format' => 'raw',

    'value' => function ($model) { 

        return $model->country->name; 



Here is the PHP.INI

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

If there is no country, I will get PHP NOTICE error (please see attached screenshot)

I have several options here

#Option 1. change the PHP.INI to ignore PHP NOTICE . Is it a good practice to do that ?

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT

#Option 2. error check $model->country before get the name

    return ($model->country) ? $model->country->name : '{not set}'; 

#Otpion 3: tell Yii to ignore all PHP NOTICE. I dont know if there is a way to do this

Which one should I do ?

Absolutely Option #2.

Check not-null value is a good pratice in every programming language (in some it is required to avoid app crash).

I like Option #2 as well.