I was migrating a code from v7.4 to 8.0 and encountered this error on one of my page but was unable to solve it i know in php v8.0 this error will be encountered as written in migrating docs
error:
Fatal error: Uncaught Error: Attempt to assign property "allow_basic" on null in /homepages/5/d742909641/htdocs/payroll/Payroll/demo/demo/allowance_setup.php:77 Stack trace: #0 {main} thrown in /homepages/5/d742909641/htdocs/payroll/Payroll/demo/demo/allowance_setup.php on line 77
Code:
$o1->allow_basic = implode("|", $allow_basic);
$o10->allow_basic = implode("|", $allow_basic);
>Solution :
The error message is clear:
Attempt to assign property "allow_basic" on null
$o1 is null before you call $o1->allow_basic, which results in the error.
You have to define $o1 as a stdClass before using it:
$o1 = new stdClass();
$o1->allow_basic = 'foo';
See the PHP documentation about stdClass: https://www.php.net/manual/en/class.stdclass.php#stdclass.properties-example