3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "\n#1: hello\n"; $a = 'hello'; var_dump($a['test']); // notice, but fetches the first char 'h' (undefined/null = 0) var_dump($a[false]); // notice, but fetches the first char 'h' (false = 0) var_dump($a[true]); // notice, but fetches the second char 'e' (true = 1) var_dump($a['2']); // notice, but fetches the second char 'e' (true = 1) echo "\n#2: 42\n"; $a = 42; var_dump($a['test']); // NO NOTICE, returns null var_dump($a[1]); // NO NOTICE, returns null var_dump($a[2]); // NO NOTICE, returns null echo "\n#2: null\n"; $a = null; var_dump($a['test']); // NO NOTICE, returns null var_dump($a[1]); // NO NOTICE, returns null var_dump($a[2]); // NO NOTICE, returns null echo "\nHave fun with it...\nbest regards,\nyour PHP";
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.5.0
#1: hello Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/XVA87:4 Stack trace: #0 {main} thrown in /in/XVA87 on line 4
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.
Output for 7.4.0 - 7.4.33
#1: hello Warning: Illegal string offset 'test' in /in/XVA87 on line 4 string(1) "h" Notice: String offset cast occurred in /in/XVA87 on line 5 string(1) "h" Notice: String offset cast occurred in /in/XVA87 on line 6 string(1) "e" string(1) "l" #2: 42 Notice: Trying to access array offset on value of type int in /in/XVA87 on line 11 NULL Notice: Trying to access array offset on value of type int in /in/XVA87 on line 12 NULL Notice: Trying to access array offset on value of type int in /in/XVA87 on line 13 NULL #2: null Notice: Trying to access array offset on value of type null in /in/XVA87 on line 17 NULL Notice: Trying to access array offset on value of type null in /in/XVA87 on line 18 NULL Notice: Trying to access array offset on value of type null in /in/XVA87 on line 19 NULL Have fun with it... best regards, your PHP
Output for 7.3.32 - 7.3.33
#1: hello Warning: Illegal string offset 'test' in /in/XVA87 on line 4 string(1) "h" string(1) "h" string(1) "e" string(1) "l" #2: 42 NULL NULL NULL #2: null NULL NULL NULL Have fun with it... best regards, your PHP
Output for 7.0.0 - 7.0.25, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.31
#1: hello Warning: Illegal string offset 'test' in /in/XVA87 on line 4 string(1) "h" Notice: String offset cast occurred in /in/XVA87 on line 5 string(1) "h" Notice: String offset cast occurred in /in/XVA87 on line 6 string(1) "e" string(1) "l" #2: 42 NULL NULL NULL #2: null NULL NULL NULL Have fun with it... best regards, your PHP

preferences:
195.08 ms | 414 KiB | 5 Q