5

At the moment I have:

$files = array_merge(
        glob($path_ . '*.js'),
        glob($path_ . '*.css'));

If the directories are empty on windows it returns an empty array. If they are empty on linux nothing is returned.

This produces this error on linux: Warning: array_merge() [function.array-merge]: Argument #1 is not an array

  • Windows: Apache:2.2.21 PHP:5.3.10
  • Linux/Debian: Apache:2.2.16 PHP:5.3.10

After some further research and testing I found that it is a bug in PHP: https://bugs.php.net/bug.php?id=53460

1
  • The quick dirty fix would be @array_merge(...) Commented Apr 6, 2012 at 11:55

1 Answer 1

4

From http://php.net/manual/en/function.glob.php:

Returns an array containing the matched files/directories, an empty array if no file matched or FALSE on error.

Check if glob($path_ . '*.js') === FALSE on linux. In this case, there is probably a permission error or something like this. It should be an empty array if there is no error, as the documentation suggests.

Also check for the case in your files/directory. Windows is case insensitive, that could explain a difference between windows and linux.

Sign up to request clarification or add additional context in comments.

5 Comments

You missed the part which says: On some systems it is impossible to distinguish between empty match and an error.
Just checked and yes it is returning FALSE. The directory is empty so can't be a file issue.
What happens if you do a scandir() or a file_exists() on your folder under linux ?
You have the error Argument #1 is not an array, this means that glob($path_ . '*.css') does not produce an error ? Does glob() return false only with .js or with both ...*.js and ...*.css. Try that with an empty folder (no js NOR css files). You should obviously have the error in both cases. Also, can you tell us what is in $path variable ?
After some further research and testing I found that it is a bug in PHP: bugs.php.net/bug.php?id=53460

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.