$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
print_r($objects);
This outputs only
RecursiveIteratorIterator Object ( )
But if you loop through the same object like
foreach($objects as $name => $object){
echo "$name\n";
}
Then it shows all the files and folders like expected.
Question: Why print_r and var_dump show that blank even after Object is created? but that loop shows all the data. Does a foreach loop through those on runtime? That's not how normally foreach works. Also the fact that var_dump or print_r for almost all other things tell everything which the object contains, then why not for this one?