Readdir is not working

software development

#1

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?

Cheers:

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

$dh = opendir(’.’);
while(($file == readdir($dh)) !== false){
echo $file.’
’;
if($file==’.’||$file==’…’){continue;};
echo ‘’.$file.’
’;
};


#2

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

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

$file

\n”;
}
}
closedir($handle);
print “

Done reading $path

\n”;
}
else {
print “

Unable to open directory: $path

\n”;
}[/code]

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


#3

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.

–rlparker

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


#4

I’ve done that.

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

Glad it wasn’t me this time!

Wholly


#5

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

Good one, cheers.


#6

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


#7

Glad you’re rockin!

Wholly