note 74594 modified in function.DirectoryIterator-construct by bjori

From: Date: Fri, 20 Apr 2007 09:14:14 +0000
Subject: note 74594 modified in function.DirectoryIterator-construct by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125590@lists.php.net to get a copy of this message
The use of this class is rather simple <?php $dataDir = dirname(__FILE__).'/world_vest_base/'; try { $dir = new DirectoryIterator($dataDir); foreach ($dir as $file) { $fileName = $file->getFilename(); } } catch (Exception $ex) { } ?> 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 --was-- 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 http://php.net/manual/en/function.DirectoryIterator-construct.php

« previous php.notes (#125590) next »