3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = '{"aasd":0}'; $user_notif = [ 'requests' => '0', 'offers' => '0', 'price_contests' => '0', 'orders' => '0', 'users' => '0', ]; $user_notif->news = 'asdasd'; var_dump(is_object(json_decode($a))); var_dump(json_encode($user_notif)); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Attempt to assign property "news" on array in /in/Z6rKI:12 Stack trace: #0 {main} thrown in /in/Z6rKI on line 12
Process exited with code 255.
Output for 7.3.24 - 7.3.33, 7.4.12 - 7.4.33
Warning: Attempt to assign property 'news' of non-object in /in/Z6rKI on line 12 bool(true) string(75) "{"requests":"0","offers":"0","price_contests":"0","orders":"0","users":"0"}"
Output for 7.1.7
Warning: Attempt to assign property of non-object in /in/Z6rKI on line 12 bool(true) string(75) "{"requests":"0","offers":"0","price_contests":"0","orders":"0","users":"0"}"

preferences:
110.76 ms | 401 KiB | 120 Q