3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master_jit, git.master, rfc.property-hooks
Deprecated: Return type of DirFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/McXa6 on line 14 pathname: /tmp/test/mydir, filename: mydir<br />

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.9 ms | 401 KiB | 8 Q