I'll try to explain myself . I want to show a list of files from a folder in a web using PHP and what I want know is what is better in time and server costs (server requests and data transmissions ) ,
Read an XML with开发者_开发问答 the list of files in it or open the folder and see the files one bye one?
P.D: The list must contain from 100 to 200 files in it.
For 100-200 files, both should be comparable operations, so I'd use whichever of the two you feel more comfortable using and implementing.
edit: As far as server requests/data transmissions, why would they be any different, if they're the same list of files?
I'm fairly certain the bottleneck will be I/O rather than PHP: either reading a file, or enumerating a directory. If you increase the # of files to thousands, you'll want to measure the results yourself.
Synchronise the list on each folder update and that should be it. Or you can read folder by using scandir() or glob(). If there aren't many requests you should be fine.
精彩评论