SPL DirectoryIterator

From: Date: Fri, 28 Jan 2005 19:09:07 +0000
Subject: SPL DirectoryIterator
Groups: php.general 
Request: Send a blank email to php-general+get-207623@lists.php.net to get a copy of this message
I'm not sure if this is a feature request, a "Oh, I didn't know that", or "That's the way it is, deal with it" kind of problem. foreach(new DirectoryIterator($sDir) as $oFile) { if($oFile->isDot() || 'hidden.txt' == $oFile->getFilename()) continue; echo $oFile,"\n"; } In the code above, I am echoing $oFile, which internally is recognizing it's being used in a string context, so calling the __toString method on itself (which then returns the result of ->getFilename()). Now, what my question is, is why won't it do that when I'm comparing values? 'hidden.txt' == $oFile Is never true, because $oFile doesn't seem to recognize it's being compared in a string context. I'm not sure I *want* it to do this, but at the moment I can't think of any reason why it couldn't behave like this. Any thoughts? http://www.php.net/~helly/php/ext/spl/classDirectoryIterator.html Chris

« previous php.general (#207623) next »