3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace foo\bar; function get_declared_classes($in_namespace = null) { if ($in_namespace === null) { yield get_declared_classes(); } if ($in_namespace{0} == '\\') { $in_namespace = substr($in_namespace, 1); } if (substr($in_namespace, -1) != '\\') { $in_namespace .= '\\'; } $classes = get_declared_classes(); $filter = new RegexIterator(new ArrayIterator($classes), '/^' .preg_quote($in_namespace). '.*$'); foreach ($filter as $class) { yield $class; } } foreach (get_declared_classes("foo\\bar") as $class) { var_dump($class); }
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.6
Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/NbISH 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/NbISH on line 11 Fatal error: Uncaught Error: Class 'foo\bar\RegexIterator' not found in /in/NbISH:20 Stack trace: #0 /in/NbISH(26): foo\bar\get_declared_classes('foo\\bar\\') #1 {main} thrown in /in/NbISH on line 20
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Fatal error: Uncaught Error: Class 'foo\bar\RegexIterator' not found in /in/NbISH:20 Stack trace: #0 /in/NbISH(26): foo\bar\get_declared_classes('foo\\bar\\') #1 {main} thrown in /in/NbISH on line 20
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Class 'foo\bar\RegexIterator' not found in /in/NbISH on line 20
Process exited with code 255.

preferences:
173.38 ms | 402 KiB | 213 Q