Readdir is not working

I got a snobbish reply from customer service about this - they suggested a problem with my code!

Very rude, never have problems with this procedure on other servers, and they suggested I compile my own version! - Very slack. I feel it is not my job to make the server work according to the PHP manual.

Anyhow, searching has not helped me solve this problem, so can anyone suggest what the story is?


Does not echo anything, not even an error, regardless what path I give it!!

$dh = opendir(’.’);
while(($file == readdir($dh)) !== false){
echo $file.’
echo ‘’.$file.’

Oh noes! You have a bug!

Well if you modify the source and compile your own version, you can fix the bugs in your PHP code by turning them into features instead! Wait…does this mean Microsoft has invaded DreamHost? And how dare they not fix your bugs since you pay them to host your site! Software development should be included free.

I feel it is not my job to debug your code. How about we switch, you debug your code and I’ll make the server work according to the manual? I really can’t decide which one will be easier!

Well since == is not an assignment operator $file never gets a value and it goes downhill from there.

Now tell me was DreamHost support as snobbish and rude as me? I wanna be better than them at something.

Oh and BTW in case you are curious here is code that actually works:[code]$dh = ‘.’;
$path = realpath($path);

if ($handle = opendir($path)) {
print “

Reading filenames in $path

while (false !== ($file = readdir($handle))) {
if ($file != ‘.’ and $file != ‘…’ and filetype($path.’/’.$file) == ‘file’) {
print “


print “

Done reading $path

else {
print “

Unable to open directory: $path


:cool: [color=#6600CC]Atropos[/color] |

NO! How dare they!? :open_mouth:

Sorry, not a clue (of course, I’m not even looking at your code - I wouldn’t want to appear to be “snobbish” and apparently you are convinced that your code is above reproach :wink: ).

That said, readdir does work at Dreamhost:

<?php // For PHP3, use: $directory = '.'; $directory = getcwd (); $directory_stream = @ opendir ($directory) or die ("Could not open a directory stream for $directory"); while ($entry = readdir ($directory_stream)) { // Grab the extension of the file $extension = substr ($entry, strrpos ($entry, '.')); switch ($extension) { case '.php': case '.phps': case '.php3': case '.phtml': print "
\n$entry"; break; default: break; } } ?>

Throw this in a directory with some files of the indicated filetype and see for yourself.


[i]Edit: Oops! Atropos7 answered while I was typing - I apologize for the similar reply. - "what he said! :slight_smile:

I’ve done that.

I think I’ve even posted code with that bug in it.

Glad it wasn’t me this time!


Thanks for pointing that out, the commentary was entertaining too!

Good one, cheers.

Yes it works and now I feel sheepish as hell, so thanks for your help

Glad you’re rockin!