3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "The 'Wee, inline callables are sort of function things' "; class q {function foo($str) {return 'moo '.$str; } } var_dump(([new q, 'foo'])('cow')); function bar( ) { return 'cow'; } var_dump('bar'( )); echo "The 'I'm amazed PHP doesn't mess this up' "; foreach ($Array = [[12 => 'Moo'], [13 => 'Cow']] as $Array) { var_dump($Array); } echo "The 'PHP Variables MUST NOT contain some symbols... for very soft values of MUST NOT' "; ${'$0a'} = 12; ${'0a'} = 13; var_dump(${'$0a'}); var_dump(${'0a'}); // $0a is invalid and $$0a is even more invalid, with spinkles echo "The 'Good luck and thanks for all the cows' "; @var_dump(0x2&${$Array=['cow'=>3]}['cow']); echo "The 'Hurrah BC breaks, if your program broke because of this you're a bad person' "; list($a[],$a[])=$a=[1,2]; var_dump($a);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
The 'Wee, inline callables are sort of function things' string(7) "moo cow" string(3) "cow" The 'I'm amazed PHP doesn't mess this up' array(1) { [12]=> string(3) "Moo" } array(1) { [13]=> string(3) "Cow" } The 'PHP Variables MUST NOT contain some symbols... for very soft values of MUST NOT' int(12) int(13) The 'Good luck and thanks for all the cows' int(2) The 'Hurrah BC breaks, if your program broke because of this you're a bad person' array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(1) [3]=> int(2) }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 The 'Wee, inline callables are sort of function things' string(7) "moo cow" string(3) "cow" The 'I'm amazed PHP doesn't mess this up' array(1) { [12]=> string(3) "Moo" } array(1) { [13]=> string(3) "Cow" } The 'PHP Variables MUST NOT contain some symbols... for very soft values of MUST NOT' int(12) int(13) The 'Good luck and thanks for all the cows' int(2) The 'Hurrah BC breaks, if your program broke because of this you're a bad person' array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(1) [3]=> int(2) }

preferences:
160.88 ms | 403 KiB | 166 Q