note 111910 added to function.is-dir

From: Date: Wed, 10 Apr 2013 19:20:09 +0000
Subject: note 111910 added to function.is-dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-194434@lists.php.net to get a copy of this message
PITFALL in sub dir processing After struggeling with a sub-dir processing (some subdirs were skipped) AND reading the posts, I realized that virutally no-one clearly told what were wrong. The common traverse dir code was: ----------------------------------------- opendir("myphotos"); // Top dir to process from (example) while (false !== ($fname = readdir($h_dir))) { // process current dir (read a directory entry) if ($fname{0} == '.') continue; // skip dirs . and .. by first char test if (is_dir($fname)) call_own_subdir_process; // process this subdir by calling a routine } PROBLEM IS : The "is_dir()" must have the FULL PATH or it will skip some dirs. So the above code need to INSERT THE PATH before the filename. This would give this change in above... if (is_dir("myphotos\" . $fname)) call_own_subdir_process; // skip subdirs The pitfall really was, that without full path some subdirs were found...hope this clears all up ---- Server IP: 195.184.96.15 Probable Submitter: 87.72.51.69 ---- Manual Page -- http://php.net/manual/en/function.is-dir.php Edit -- https://master.php.net/note/edit/111910 Del: integrated -- https://master.php.net/note/delete/111910/integrated Del: useless -- https://master.php.net/note/delete/111910/useless Del: bad code -- https://master.php.net/note/delete/111910/bad+code Del: spam -- https://master.php.net/note/delete/111910/spam Del: non-english -- https://master.php.net/note/delete/111910/non-english Del: in docs -- https://master.php.net/note/delete/111910/in+docs Del: other reasons-- https://master.php.net/note/delete/111910 Reject -- https://master.php.net/note/reject/111910 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194434) next »