Reputation: 777
I'm getting that error when trying to use this code
<?php
$fi = new FilesystemIterator("image/Images", FilesystemIterator::SKIP_DOTS);
$count = iterator_count($fi);
if ($count-2<0){
$i = 0;
}
else{
$i = $count -2;
}
echo $i;
?>
Is there an alternative to what I have written? I think it might be something to do with my version of php on my webhost... I don't want to change the version though, so a work around would be helpful.
Upvotes: 2
Views: 1517
Reputation: 7080
As @Mark Baker mentioned on comment -
FileSystemIterator requires PHP >= 5.3.0
and my PHP version is lower than 5.3.0 , I upgraded that fixed my problem.
Either you could check phpversion
or class_exists
before calling FileSystemIterator
Upvotes: 0