3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public ?string $foo; public string $foobar; public ?string $bar = ''; } $vars = get_object_vars(new A); var_dump(assert(array_key_exists('bar', $vars)) ? 'bar exists in $vars' : 'bar does not exist in $vars'); var_dump(assert(array_key_exists('foobar', $vars)) ? 'foobar exists in $vars' : 'foobar does not exist in $vars'); var_dump(assert(array_key_exists('foo', $vars)) ? 'foo exists in $vars' : 'foo does not exist in $vars');
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.4, 8.3.6
string(19) "bar exists in $vars" Fatal error: Uncaught AssertionError: assert(array_key_exists('foobar', $vars)) in /in/eg6o0:12 Stack trace: #0 /in/eg6o0(12): assert(false, 'assert(array_ke...') #1 {main} thrown in /in/eg6o0 on line 12
Process exited with code 255.
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 string(19) "bar exists in $vars" Fatal error: Uncaught AssertionError: assert(array_key_exists('foobar', $vars)) in /in/eg6o0:12 Stack trace: #0 /in/eg6o0(12): assert(false, 'assert(array_ke...') #1 {main} thrown in /in/eg6o0 on line 12
Process exited with code 255.
Output for 7.4.0 - 7.4.33
string(19) "bar exists in $vars" Warning: assert(): assert(array_key_exists('foobar', $vars)) failed in /in/eg6o0 on line 12 string(30) "foobar does not exist in $vars" Warning: assert(): assert(array_key_exists('foo', $vars)) failed in /in/eg6o0 on line 13 string(27) "foo does not exist in $vars"
Output for 7.1.26 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Parse error: syntax error, unexpected '?', expecting function (T_FUNCTION) or const (T_CONST) in /in/eg6o0 on line 4
Process exited with code 255.

preferences:
163.94 ms | 402 KiB | 188 Q