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 */ var_dump($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/d0R8o on line 14 object(SplFileInfo)#10 (2) { ["pathName":"SplFileInfo":private]=> string(11) "/tmp/test/." ["fileName":"SplFileInfo":private]=> string(1) "." } object(SplFileInfo)#12 (2) { ["pathName":"SplFileInfo":private]=> string(12) "/tmp/test/.." ["fileName":"SplFileInfo":private]=> string(2) ".." } object(SplFileInfo)#10 (2) { ["pathName":"SplFileInfo":private]=> string(15) "/tmp/test/mydir" ["fileName":"SplFileInfo":private]=> string(5) "mydir" } object(SplFileInfo)#14 (2) { ["pathName":"SplFileInfo":private]=> string(17) "/tmp/test/mydir/." ["fileName":"SplFileInfo":private]=> string(1) "." } object(SplFileInfo)#15 (2) { ["pathName":"SplFileInfo":private]=> string(18) "/tmp/test/mydir/.." ["fileName":"SplFileInfo":private]=> string(2) ".." }

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:
28.34 ms | 404 KiB | 8 Q