Environment:
Laravel Version: 5.5
PHP Version: 7.4.0
Error stack trace:Message: Trying to access array offset on value of type null
Sample code that gave me error:$filterConfig = $request->get('filterConfig', null);
$showAll = $filterConfig['show']['all'] === 'true'? true: false;
The error was coming because $filterConfig was getting initialized by null in the first line and I was fetching $filterConfig[‘show’][‘all’] in the second line. Hence, it was throwing an error by saying Trying to access array offset on value of type null
NOTE: This error only comes if you have upgraded to PHP 7.4
Solution:
if (isset($filterConfig) && isset($filterConfig['show']['all'])) {
$showAll = true;
} else {
$showAll = false;
}
- MyHospitalNow.com – PROD | Clean all patient user and related quote, bid and file data - March 21, 2020
- Sending Email with attachments in Laravel 5.5 using and PHP & JQuery - February 20, 2020
- How to run php artisan queue:listen in background on Ubuntu or Linux machine - February 6, 2020