Wild guess. From
http://php.net/manual/en/function.scandir.php
array scandir ( string $directory [, int $sorting_order = SCANDIR_SORT_ASCENDING [, resource $context ]] )
I’m thinking you put the CONSTANT inside quotes making it a string. eg.
correct
$dir_contents = scandir('somefolder', SCANDIR_SORT_DESCENDING);
wrong
$dir_contents = scandir('somefolder', 'SCANDIR_SORT_DESCENDING');