FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » sorting readdir output?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: sorting readdir output? [message #184023 is a reply to message #184022] Mon, 02 December 2013 21:33 Go to previous messageGo to previous message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma:
Senior Member
Richard Yates wrote:

> I understand the warning as it applies to many functions. Perhaps I
> should have asked why there would ever be a valid result of a
> directory read that evaluates to false. In practice, reading his own
> directory, would he ever actually encounter a file named "0" or
> "false"?

Using the explicit check for !== FALSE seems reasonable anyway. A file
named "0" might exists, and maybe there are some strange filenames that
are returned as empty string (not sure, if that could happen, though).
The filename "false", however, == TRUE.

OTOH, implicitely checking for == FALSE, would catch an error where
opendir() returned FALSE (for instance, because the directory does not
exist). In this case the OP's code would call readdir() with FALSE as
argument, what would cause readdir() to return NULL.

A better solution would check for the return value of opendir() in the
first place.

--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: dropdown menus
Next Topic: Re: SEO SERVICES
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 04:25:24 GMT 2024

Total time taken to generate the page: 0.04487 seconds