Skip to content
Advertisement

Attempt to assign property “status” on null

I have the following code running on PHP 7.4.2, but after the update to PHP 8.1.2, I’m getting an error in order to fill an array with some data.

JavaScript

I’m getting the following error:

Fatal error: Uncaught Error: Attempt to assign property “status” on null

Is this problem related to some change in PHP 8? I’ve tried to find some answers but have no success on how I can update the code to run in this new scenario.

Advertisement

Answer

You need to create $myObj before you can assign to $myObj->status.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement