note 74594 added to function.DirectoryIterator-construct

From: Date: Thu, 19 Apr 2007 08:58:46 +0000
Subject: note 74594 added to function.DirectoryIterator-construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-125563@lists.php.net to get a copy of this message
The use of this class is rather simple [code] $dataDir = dirname(__FILE__).'/world_vest_base/'; try { $dir = new DirectoryIterator($dataDir); foreach ($dir as $file) { $fileName = $file->getFilename(); } } catch (Exception $ex) { } [/code] If $dataDir is null, a Runtime Exception will throws a message like this: Directory name must not be empty. If $dataDir does not exist, that message will look like this: failed to open dir: No such file or directory. Please be careful in case you are looking for filenames in that directory because DirectoryIterator will return a very special symbolic filenames: . and .. You must do a check to ignore them before dealing with real file names. $dir is a DirectoryIterator object ---- Server IP: 69.147.83.197 Probable Submitter: 210.245.51.187 ---- Manual Page -- http://www.php.net/manual/en/function.DirectoryIterator-construct.php Edit -- https://master.php.net/note/edit/74594 Del: integrated -- https://master.php.net/note/delete/74594/integrated Del: useless -- https://master.php.net/note/delete/74594/useless Del: bad code -- https://master.php.net/note/delete/74594/bad+code Del: spam -- https://master.php.net/note/delete/74594/spam Del: non-english -- https://master.php.net/note/delete/74594/non-english Del: in docs -- https://master.php.net/note/delete/74594/in+docs Del: other reasons-- https://master.php.net/note/delete/74594 Reject -- https://master.php.net/note/reject/74594 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125563) next »