# PHP's glob function running PHP-FPM on FreeBSD



## Ben (May 21, 2013)

Hi,

I have a strange problem which only occurs on my FreeBSD servers. I have a PHP file with the following code: 

```
<?php
var_dump(glob("css/*"));
```
Run via Nginx/PHP-FPM this returns the content of the directory css. If the directory is empty it returns FALSE. If I run it via the shell it works as intended (returning an empty array).

Any idea?

Thanks.


----------



## SirDice (May 21, 2013)

If glob() returns FALSE there has been an error. You need to figure out what the error is.



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



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


----------



## Ben (May 21, 2013)

Yes, I know. But I don't know how to figure it out.

When I run `php test.php` it returns an empty array if the directory is empty, otherwise it returns the files. When I run it via php-fpm it returns an array of files or false. If it would be a permission issue it would not return me the files.


----------



## SirDice (May 21, 2013)

What version of PHP? I see a bug that looks similar that has been fixed not too long ago:
https://bugs.php.net/bug.php?id=47358


----------



## Ben (May 21, 2013)

Interesting, when I switch off open_basedir (as suggested) it works.

My PHP version is quite recent.

```
PHP 5.4.15 (cli) (built: May 15 2013 17:13:10) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.1, Copyright (c) 1999-2013, by Zend Technologies
```

Thanks for your help.


----------

