note 113773 added to function.scandir
| From: | arfon at cradur dot com | Date: | Fri, 29 Nov 2013 12:35:51 +0000 |
| Subject: | note 113773 added to function.scandir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197660@lists.php.net to get a copy of this message | ||
Care needed going from PHP 5.3 to 5.4, as the constant SCANDIR_SORT_DESCENDING is only defined from
5.4.
I had previously been using literal, i.e. scandir($targetDir,2) in 5.3, but this did not give
desired result in 5.4 (Ascending is default). However when I used SCANDIR_SORT_DESCENDING which is
not defined in 5.3, on my web host (still on 5.3) I got error - second argument assumed to be a
string.
My solution (very primitive):
$sort_desc = defined('SCANDIR_SORT_DESCENDING') ?
SCANDIR_SORT_DESCENDING : 2;
$infiles = scandir($targetDir, $sort_desc);
----
Server IP: 64.71.164.2
Probable Submitter: 95.147.218.228
----
Manual Page -- http://php.net/manual/en/function.scandir.php
Edit -- https://master.php.net/note/edit/113773
Del: integrated -- https://master.php.net/note/delete/113773/integrated
Del: useless -- https://master.php.net/note/delete/113773/useless
Del: bad code -- https://master.php.net/note/delete/113773/bad+code
Del: spam -- https://master.php.net/note/delete/113773/spam
Del: non-english -- https://master.php.net/note/delete/113773/non-english
Del: in docs -- https://master.php.net/note/delete/113773/in+docs
Del: other reasons-- https://master.php.net/note/delete/113773
Reject -- https://master.php.net/note/reject/113773
Search -- https://master.php.net/manage/user-notes.php