3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace foo\bar; function get_declared_classes($in_namespace = null) { if ($in_namespace === null) { return \get_declared_classes(); } if ($in_namespace{0} == '\\') { $in_namespace = substr($in_namespace, 1); } if (substr($in_namespace, -1) != '\\') { $in_namespace .= '\\'; } $filter = new \RegexIterator(new \ArrayIterator(\get_declared_classes()), '/^' .\preg_quote($in_namespace). '.*$'); return \iterator_to_array($filter); } var_dump(get_declared_classes("foo\bar"));
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
Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/8ZBZt on line 11
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 Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/8ZBZt on line 11
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/8ZBZt on line 11 Fatal error: Uncaught InvalidArgumentException: RegexIterator::__construct(): No ending delimiter '/' found in /in/8ZBZt:19 Stack trace: #0 /in/8ZBZt(19): RegexIterator->__construct(Object(ArrayIterator), '/^foo\\\\bar\\\\.*$') #1 /in/8ZBZt(23): foo\bar\get_declared_classes('foo\\bar\\') #2 {main} thrown in /in/8ZBZt on line 19
Process exited with code 255.
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
Fatal error: Uncaught InvalidArgumentException: RegexIterator::__construct(): No ending delimiter '/' found in /in/8ZBZt:19 Stack trace: #0 /in/8ZBZt(19): RegexIterator->__construct(Object(ArrayIterator), '/^foo\\\\bar\\\\.*$') #1 /in/8ZBZt(23): foo\bar\get_declared_classes('foo\\bar\\') #2 {main} thrown in /in/8ZBZt on line 19
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'RegexIterator::__construct(): No ending delimiter '/' found' in /in/8ZBZt:19 Stack trace: #0 /in/8ZBZt(19): RegexIterator->__construct(Object(ArrayIterator), '/^foo\\\\bar\\\\.*$') #1 /in/8ZBZt(23): foo\bar\get_declared_classes('foo\\bar') #2 {main} thrown in /in/8ZBZt on line 19
Process exited with code 255.

preferences:
144.58 ms | 402 KiB | 183 Q