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:
Rafael de Camargo 2019-08-03 22:28:04 -03:00 committed by Frédéric Guillot
parent 355de9fb45
commit ac829d4f14
1 changed files with 1 additions and 1 deletions

View File

@ -6,7 +6,7 @@ function concat_files(array $files)
{
$data = '';
foreach ($files as $pattern) {
foreach (glob($pattern) as $filename) {
foreach (glob($pattern, GLOB_ERR | GLOB_NOCHECK) as $filename) {
echo $filename.PHP_EOL;
if (! file_exists($filename)) {
die("$filename not found\n");