Trying to access array offset on value of type null
Sounds like your variable isn't set.
Check with the following isset calls:
isset($this->config); isset($this->config['backend']);isset($this->config['backend']['api_prefix']);
You can actually check multiple vars in one isset call (isset($x, $y, $z)
), but this will let you see which var specifically is missing
use (??) (double question mark operator
) ("null coalescing operator
") to avoid unsetarrays.
this unit test is giving me "success"
class PhpTest extends TestCase{ public function test_php_74() { //Trying to access array offset on value of type null $this->assertSame('7.4.9', phpversion()); $a = null; $this->assertTrue($a ?? true); $this->assertTrue($a['a'] ?? true); $this->assertTrue($a['a']['a'] ?? true); $a = []; $this->assertSame([], $a); $this->assertTrue($a['a'] ?? true); $this->assertTrue($a['a']['a'] ?? true); }}
It is related to PHP 7.4 Issue.The solution is we can put isset in PHP or Laravel BladeOld Code
@foreach ($widgets->get('dashboard') as $widget) {!! $widget->render() !!}@endforeach
New code update with isset
@if(isset($Widget))@foreach ($widgets->get('dashboard') as $widget) {!! $widget->render() !!}@endforeach@endif