Voting

: max(six, three)?
(Example: nine)

The Note You're Voting On

stuart at horuskol dot net
14 years ago
Looking through the examples, I can't see any that do a simple check on the value of the directory resource that opendir returns and is subsequently used by readdir.

If opendir returns false, and you simply pass this to the readdir call in the while loop, you will get an infinite loop.

A simple test helps prevent this:

<?php

$dir
= opendir($path);
while (
$dir && ($file = readdir($dir)) !== false) {
// do stuff
}

?>

<< Back to user notes page

To Top