3v4l.org

run code in 300+ PHP versions simultaneously
<?php $emptyobject = new stdClass(); foreach ($emptyobject as $key => $value) { echo "Empty object: {$key} = {$value}\n"; } $filledobject = new stdClass(); $filledobject->foo = "foo"; $filledobject->bar = "bar"; foreach ($filledobject as $key => $value) { echo "Filled object: {$key} = {$value}\n"; } $string = "abc"; foreach ($string as $key => $value) { echo "String: {$key} = {$value}\n"; } $number = 123; foreach ($number as $key => $value) { echo "Number: {$key} = {$value}\n"; }
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.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Filled object: foo = foo Filled object: bar = bar Warning: foreach() argument must be of type array|object, string given in /in/CCrFo on line 16 Warning: foreach() argument must be of type array|object, int given in /in/CCrFo on line 21
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 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Filled object: foo = foo Filled object: bar = bar Warning: Invalid argument supplied for foreach() in /in/CCrFo on line 16 Warning: Invalid argument supplied for foreach() in /in/CCrFo on line 21

preferences:
192.3 ms | 410 KiB | 5 Q