3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(null->user_id); // Raise the warning as expected var_dump(null->user_id ?? 0); // Without Warning
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Warning: Attempt to read property "user_id" on null in /in/LZ0RH on line 3 NULL int(0)
Output for 7.4.0 - 7.4.33
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ')' in /in/LZ0RH on line 3
Process exited with code 255.

preferences:
88.04 ms | 1256 KiB | 5 Q