Add error checks to glob function
GLOB_ERR will throw errors if an error occurs, such as lack of permission GLOB_NOCHECK will return the pattern if no file is found, this makes the file_exists check valid
This commit is contained in:
committed by
Frédéric Guillot
parent
355de9fb45
commit
ac829d4f14
@@ -6,7 +6,7 @@ function concat_files(array $files)
|
|||||||
{
|
{
|
||||||
$data = '';
|
$data = '';
|
||||||
foreach ($files as $pattern) {
|
foreach ($files as $pattern) {
|
||||||
foreach (glob($pattern) as $filename) {
|
foreach (glob($pattern, GLOB_ERR | GLOB_NOCHECK) as $filename) {
|
||||||
echo $filename.PHP_EOL;
|
echo $filename.PHP_EOL;
|
||||||
if (! file_exists($filename)) {
|
if (! file_exists($filename)) {
|
||||||
die("$filename not found\n");
|
die("$filename not found\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user