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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to