3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dir = '/tmp/test'; @mkdir($dir, 0777, true); touch($dir . '/.anyhidden'); // like .DS_Store on mac... @mkdir($dir . '/mydir'); class DirFilterIterator extends \FilterIterator { public function accept() { if ($this->current()->isDir()) { return true; } return false; } } $flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO; //$flags |= \FilesystemIterator::SKIP_DOTS; // uncomment this line to see the bug? $it = new \RecursiveDirectoryIterator($dir, $flags); $rit = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST, 0); $rit = new DirFilterIterator($rit); $iterator = new \AppendIterator(); $iterator->append($rit); foreach ($iterator as $f) { /** * @var \SplFileInfo $f */ if ('.' !== $f->getBasename() && '..' !== $f->getBasename()) { echo sprintf('pathname: %s, filename: %s', $f->getPathname(), $f->getFilename()); echo '<br />'; } }
Output for 5.3.0 - 5.5.24, 5.5.29, 5.6.7, 5.6.10, 5.6.13, 5.6.21 - 5.6.28, 7.0.2, 7.0.4 - 7.0.5, 7.0.14 - 7.1.0
pathname: /tmp/test/mydir, filename: mydir<br />
Output for 5.5.25 - 5.5.26, 5.6.8 - 5.6.9, hhvm-3.12.0, 7.0.6
pathname: /tmp/test/folder, filename: folder<br />pathname: /tmp/test/mydir, filename: mydir<br />
Output for 7.0.0 - 7.0.1, 7.0.3
Warning: touch(): Unable to create file /tmp/test/.anyhidden because Not a directory in /in/RjoTg on line 5 Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator::__construct(/tmp/test): failed to open dir: Not a directory in /in/RjoTg:27 Stack trace: #0 /in/RjoTg(27): RecursiveDirectoryIterator->__construct('/tmp/test', 0) #1 {main} thrown in /in/RjoTg on line 27
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.5.27 - 5.5.28, 5.5.30 - 5.5.35, 5.6.11 - 5.6.12, 5.6.14 - 5.6.20
Warning: touch(): Unable to create file /tmp/test/.anyhidden because Not a directory in /in/RjoTg on line 5 Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(/tmp/test): failed to open dir: Not a directory' in /in/RjoTg:27 Stack trace: #0 /in/RjoTg(27): RecursiveDirectoryIterator->__construct('/tmp/test', 0) #1 {main} thrown in /in/RjoTg on line 27
Process exited with code 255.
Output for 5.0.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 9 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 21 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 22 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 27 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 31 Fatal error: Class 'FilesystemIterator' not found in /in/RjoTg on line 21
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 9 Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/RjoTg on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 9 Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/RjoTg on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/RjoTg on line 9 Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/RjoTg on line 11
Process exited with code 255.