Do not get errors like “yii\base\ErrorException: Trying to access array offset on the value of type null” in the yii2 local server. But live server return error. How do I configure the environment setting to get all errors for yii2?
Do not get errors like “yii\base\ErrorException: Trying to access array offset on the value of type null” in the yii2 local server. But live server return error. How do I configure the environment setting to get all errors for yii2?
Different php versions?
Without seeing the relevant code, it will be hard to say for sure. May be as @InsaneSkull said, it is a code that depends on some functionality that behaves different among different PHP versions. Or it might be environment dependent code… or anything else!
Hi,
I am using the same version in local, staging, and live.I am working on dockerMy error log settings is here
‘targets’ => [
[
‘class’ => ‘yii\log\FileTarget’,
‘levels’ => [‘error’],
],
[
‘class’ => ‘yii\log\DbTarget’,
‘levels’ => [‘error’, ‘warning’],
],
[
‘class’ => ‘yii\log\EmailTarget’,
‘mailer’ => ‘mailer’,
‘except’ => [‘yii\web\HttpException:404’],
‘levels’ => [‘error’],
‘message’ => [
‘from’ => [‘rns@rensup.com’],
‘to’ => [‘maya.a@loremine.com’,‘anju.joseph@loremine.com’],
‘subject’ => ‘rns-live - Error’,
],
],
],
],
Thanks and regards
Maya A
What does this mean?
Could you show us the code that produces this error?
Hi,
Here is my code that returns the error “Trying to access array offset on the value of type null”
if($roomExists[‘id’] > 0){
}
But the error doesn’t show on the local server
When I used
!empty($roomExist),
the error disappeared in the live site.
Thanks & Regards
Maya A
you should use this check and your error may be because of different data that will be sometimes empty
Your code lacks context. But what it means is that by the time that line is reached, $roomExists
is already null. If that is not expected debug your code