- var_dump: documentation ( source)
- dirname: documentation ( source)
- phpversion: documentation ( source)
<?php
function test_iterator($dirname) {
$files = array();
$dir = new DirectoryIterator($dirname);
while($dir->valid()) {
$files[] = (string)$dir->current();
$dir->next();
}
return $files;
}
function test_iterator_bug($dirname) {
$files = array();
$dir = new DirectoryIterator($dirname);
foreach($dir as $file) {
$files[] = (string)$file;
}
return $files;
}
echo 'PHP version: ' . phpversion() . "\n\n";
$dirname = dirname(__FILE__);
foreach (array('iterator', 'iterator_bug') as $test_name) {
echo "--- {$test_name} ---\n";
$foo = "test_{$test_name}";
var_dump($foo($dirname));
echo "\n";
}