php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #43648 Glob definition should read "mixed", not array
Submitted: 2007-12-21 03:20 UTC Modified: 2007-12-21 10:03 UTC
From: online at metrofindings dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: online at metrofindings dot com
New email:
PHP Version: OS:

 

 [2007-12-21 03:20 UTC] online at metrofindings dot com
Description:
------------
The definition of glob in the PHP documentation reports that glob() 
returns an array.  But the section on return values clearly states 
that sometimes FALSE is returned.  The function definition should 
report a mixed return value.

Also, the return values section says that glob() returns false if 
the files cannot be read.  This is not true.  glob() only returns 
false if the files cannot be read *and* safe_mode is on.


http://us2.php.net/glob



Reproduce code:
---------------
su
mkdir foobar;
touch foobar/stuff
chmod a-rx foobar/stuff
chmod a-rx foobar/
exit

php -c /etc/php.ini glob.php (with safe_mode off)

string(12) "foobar/stuff"
array(0) {
}

php -c /etc/php.ini glob.php (with safe_mode on)

string(12) "foobar/stuff"
bool(false)

Warning: Invalid argument supplied for foreach() in glob.php on line 8

glob.php
============================================
<?php

$filesToRemove = glob( dirname(__FILE__).'/foobar/stuff' );
var_dump( dirname(__FILE__).'/foobar/stuff' );

var_dump($filesToRemove);

foreach ($filesToRemove as $k => $v) {
}
?>


Expected result:
----------------
Documentation of return type "mixed".
Better note that correctly identifies "safe_mode" as the reason for 
returning false.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-21 10:03 UTC] felipe@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Bug #43530

Thanks.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 04:00:01 2026 UTC