3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isNull($id, $userInfo){ If($userInfo[$id] == 0){ $res = "Не указано"; } else{ $res = $userInfo["$id"]; } return $res; } $city = isNull($userInfo,"city")->title;
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
Warning: Undefined variable $userInfo in /in/Sc6bc on line 11 Warning: String offset cast occurred in /in/Sc6bc on line 3 Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/Sc6bc:7 Stack trace: #0 /in/Sc6bc(11): isNull(NULL, 'city') #1 {main} thrown in /in/Sc6bc on line 7
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined variable: userInfo in /in/Sc6bc on line 11 Notice: String offset cast occurred in /in/Sc6bc on line 3 Notice: Trying to get property 'title' of non-object in /in/Sc6bc on line 11
Output for 7.3.32 - 7.3.33, 7.4.26
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Notice: Undefined variable: userInfo in /in/Sc6bc on line 11 Notice: String offset cast occurred in /in/Sc6bc on line 3 Notice: Trying to get property of non-object in /in/Sc6bc on line 11

preferences:
214.14 ms | 402 KiB | 292 Q