I am using PHP 5’s scandir($dir) function to iterate through a directory and print out an xml list of files. Only, when the directory has a single quote in the name, scandir returns no items! It doesn’t return false (as it would if it failed) or generate warnings or errors – just empty. Any ideas?
$items = scandir(stripslashes($dir)); //strip slashes in case magic_quotes are on if($items === false) die('scandir returned failure'); print_r($items)
I’ve tested it on windows and it worked fine. Try
echo $dir;to make sure it’s what you expect.Also, use
ini_set()to make sure your error level is high enough: