|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-06 19:15 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 16:00:02 2025 UTC |
Description: ------------ Hi! I try this code but it's a strange result. I don't receive same result for '.' directory. Here is my directories structure : # ll -R tmptest/ tmptest/: total 12 -rw-r--r-- 1 apache apache 21 avr 6 15:56 tmpfile.txt lrwxrwxrwx 1 apache apache 11 avr 6 15:56 tmplink.lnk -> tmpfile.txt drwxr-xr-x 3 apache apache 4096 avr 6 15:56 tmpsubtest drwxr-xr-x 2 apache apache 4096 avr 6 15:56 tmpsubtest2 tmptest/tmpsubtest: total 4 drwxr-xr-x 2 apache apache 4096 avr 6 15:56 tmpsubsubtest tmptest/tmpsubtest/tmpsubsubtest: total 4 -rw-r--r-- 1 apache apache 21 avr 6 15:56 tmpfile.txt tmptest/tmpsubtest2: total 0 Reproduce code: --------------- <?php $rdi = new RecursiveDirectoryIterator('tmptest'); // -------- HERE CUT and PASTE X5 code bellow ------- echo '#############################<br />'; echo '__toString is = ['.$rdi.']<br />'; echo 'Current is = ['.$rdi->current().']<br />'; echo 'Key is = ['.$rdi->key().']<br />'; echo 'Valid is = ['.$rdi->valid().']<br />'; echo 'hasChildren is = ['.$rdi->hasChildren().']<br />'; $rdi->next(); // -------- HERE CUT and PASTE END ------- $rdi->rewind(); foreach ($rdi as $content) { echo '++++++++++++++++++++++++++++++<br />'; echo '__toString is = ['.$rdi.']<br />'; echo 'Current is = ['.$rdi->current().']<br />'; echo 'Key is = ['.$rdi->key().']<br />'; echo 'Valid is = ['.$rdi->valid().']<br />'; echo 'hasChildren is = ['. $rdi->hasChildren().']<br />'; } ?> Expected result: ---------------- ############################# __toString is = [tmpsubtest2] Current is = [tmptest/tmpsubtest2] Key is = [tmptest/tmpsubtest2] Valid is = [1] hasChildren is = [1] ############################# __toString is = [tmpsubtest] Current is = [tmptest/tmpsubtest] Key is = [tmptest/tmpsubtest] Valid is = [1] hasChildren is = [1] ############################# __toString is = [tmpfile.txt] Current is = [tmptest/tmpfile.txt] Key is = [tmptest/tmpfile.txt] Valid is = [1] hasChildren is = [] ############################# __toString is = [.tmpfilehidden.txt] Current is = [tmptest/.tmpfilehidden.txt] Key is = [tmptest/.tmpfilehidden.txt] Valid is = [1] hasChildren is = [] ############################# __toString is = [tmplink.lnk] Current is = [tmptest/tmplink.lnk] Key is = [tmptest/tmplink.lnk] Valid is = [1] hasChildren is = [] ############################# ++++++++++++++++++++++++++++++ __toString is = [tmpsubtest2] Current is = [tmptest/tmpsubtest2] Key is = [tmptest/tmpsubtest2] Valid is = [1] hasChildren is = [1] ++++++++++++++++++++++++++++++ __toString is = [tmpsubtest] Current is = [tmptest/tmpsubtest] Key is = [tmptest/tmpsubtest] Valid is = [1] hasChildren is = [1] ++++++++++++++++++++++++++++++ __toString is = [tmpfile.txt] Current is = [tmptest/tmpfile.txt] Key is = [tmptest/tmpfile.txt] Valid is = [1] hasChildren is = [] ++++++++++++++++++++++++++++++ __toString is = [.tmpfilehidden.txt] Current is = [tmptest/.tmpfilehidden.txt] Key is = [tmptest/.tmpfilehidden.txt] Valid is = [1] hasChildren is = [] ++++++++++++++++++++++++++++++ __toString is = [tmplink.lnk] Current is = [tmptest/tmplink.lnk] Key is = [tmptest/tmplink.lnk] Valid is = [1] hasChildren is = [] Actual result: -------------- In my result, these lines are add in first place. I don't find '..' directory, only '.' and method RecursiveDirectoryIterator::isDot() == True. ############################# __toString is = [.] Current is = [tmptest/.] Key is = [tmptest/.] Valid is = [1] hasChildren is = []