php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #43530 glob returns FALSE instead of empty array when no files matched
Submitted: 2007-12-07 20:31 UTC Modified: 2008-04-13 23:50 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: Numa dot Haase at uvm dot edu Assigned: bjori (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.5 OS: Solaris
Private report: No CVE-ID: None
 [2007-12-07 20:31 UTC] Numa dot Haase at uvm dot edu
Description:
------------
What I am reporting seems to me be the same as Bug #43461, but Jani and Ilia took the problem to be as in Bug #43407 where a directory in the path does not exist.  Here we are in the current directory but simply cannot match any files.  The documentation clearly states that in such a case the function will return an empty array.

Nevertheless, we turned safe_mode off to see what would happen, and glob then returned an empty array as expected.  However, we cannot run our web server with safe mode off.  I think this was working up until the latest version 5.2.5.  I can write everything with the opendir,  readdir, etc. functions even with safe_mode on, so I don't quite follow Ilia's logic about bypassing safe_mode, but in any case, if the directory exists glob should return an empty array when no files are matched whether safe_mode is on or not.  If not, the returned array from glob cannot be used (as it often is) in other functions expecting an array argument, and many things will break in a lot of existing code. If glob's behavior has indeed changed, then it needs to be noted in the documentation. 

Reproduce code:
---------------
glob("*.jpg");

Expected result:
----------------
empty array

Actual result:
--------------
boolean FALSE

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-07 23:56 UTC] jani@php.net
Reclassified.
 [2007-12-12 15:24 UTC] felipe@php.net
In PHP 5.3 returns empty array.
 [2008-04-13 23:50 UTC] bjori@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun May 11 22:01:27 2025 UTC