3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"));
based on j46ks
Output for 7.0.0 - 7.2.0
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.4.29 - 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.
Output for 5.4.27 - 5.4.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\\barr) #2 {main} thrown in /in/8ZBZt on line 19
Process exited with code 255.
Output for 5.3.19 - 5.4.26
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.