3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $psr4 = array( 'my\\first\\ns\\prefix\\' => 0, 'my\\second\\ns\\prefix\\' => 0, 'my\\third\\ns\prefix' => 0, ); foreach ($psr4 as $prefix => &$v) { $v = strlen($prefix); } $classes = array( 'my\\third\\ns\\prefix\\subns\\class', 'another\\ns\\prefix\\subns\\class', ); for ($i = 0; $i < 1000; $i++) { foreach ($classes as $class) { foreach ($psr4 as $prefix => $length) { if (!strncmp($class, $prefix, $length)) { //echo "$class -> $prefix\n"; break; } } } }
based on Xpe7t
Output for 5.0.0 - 7.2.0
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/7nc4j on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/7nc4j on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/7nc4j on line 8
Process exited with code 255.