3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace foo\bar { class bat { }; 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); } } namespace foo\bar\baz { class qux { } } namespace { var_dump(\foo\bar\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/1BOnv on line 13
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/1BOnv on line 13
Process exited with code 255.
Output for 7.4.33
Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/1BOnv on line 13 array(2) { [140]=> string(11) "foo\bar\bat" [141]=> string(15) "foo\bar\baz\qux" }
Output for 7.4.0 - 7.4.32
Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/1BOnv on line 13 array(2) { [162]=> string(11) "foo\bar\bat" [163]=> string(15) "foo\bar\baz\qux" }
Output for 7.3.32 - 7.3.33
array(2) { [139]=> string(11) "foo\bar\bat" [140]=> string(15) "foo\bar\baz\qux" }
Output for 7.3.0 - 7.3.31
array(2) { [160]=> string(11) "foo\bar\bat" [161]=> string(15) "foo\bar\baz\qux" }
Output for 7.2.6 - 7.2.33
array(2) { [158]=> string(11) "foo\bar\bat" [159]=> string(15) "foo\bar\baz\qux" }
Output for 7.2.0
array(2) { [157]=> string(11) "foo\bar\bat" [158]=> string(15) "foo\bar\baz\qux" }
Output for 7.1.0 - 7.1.33
array(2) { [156]=> string(11) "foo\bar\bat" [157]=> string(15) "foo\bar\baz\qux" }
Output for 7.0.0 - 7.0.4, 7.0.20
array(2) { [153]=> string(11) "foo\bar\bat" [154]=> string(15) "foo\bar\baz\qux" }
Output for 7.0.6
array(2) { [152]=> string(11) "foo\bar\bat" [153]=> string(15) "foo\bar\baz\qux" }
Output for 7.0.5
array(2) { [133]=> string(11) "foo\bar\bat" [134]=> string(15) "foo\bar\baz\qux" }
Output for 5.6.8 - 5.6.12, 5.6.16 - 5.6.19, 5.6.28
array(2) { [143]=> string(11) "foo\bar\bat" [144]=> string(15) "foo\bar\baz\qux" }
Output for 5.5.24 - 5.5.28, 5.5.31 - 5.5.33, 5.5.35, 5.6.21
array(2) { [142]=> string(11) "foo\bar\bat" [143]=> string(15) "foo\bar\baz\qux" }
Output for 5.6.13 - 5.6.15, 5.6.20
array(2) { [124]=> string(11) "foo\bar\bat" [125]=> string(15) "foo\bar\baz\qux" }
Output for 5.5.29 - 5.5.30, 5.5.34
array(2) { [123]=> string(11) "foo\bar\bat" [124]=> string(15) "foo\bar\baz\qux" }

preferences:
177.14 ms | 401 KiB | 213 Q