|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60204 glob() function parameter string limited to 50 characters
Submitted: 2011-11-02 18:49 UTC Modified: 2013-02-18 00:35 UTC
Avg. Score:3.5 ± 0.5
Reproduced:0 of 0 (0.0%)
From: fred dot demers at gmail dot com Assigned:
Status: No Feedback Package: Documentation problem
PHP Version: 5.3.8 OS: Windows XP SP2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-11-02 18:49 UTC] fred dot demers at gmail dot com
From manual page:
Documentation shortcoming for glob().

glob() does not seem to find any pattern that is longer than 50 characters.

In particular, if one expands the search pattern to remove case sensitivity using sql_regcase() or an equivalent function as available the glob() manual page, (eg. which transforms "cake*" into "[cC][aA][kK][eE]*"), the number of characters is reduced four times to about 12 characters.

This 50 character limitation should be documented in my opinion.

Test script:
//recursive glob() find 
function find($dir, $pattern){

 //get a list of all matching files in the current directory
 $files = glob("$dir/".$pattern);
 //find a list of all directories in the current directory
 //directories beginning with a dot are also included
     foreach (glob("$dir/{.[^.]*,*}", GLOB_BRACE|GLOB_ONLYDIR) as $sub_dir){
         $arr   = find($sub_dir, $pattern);  // resursive call
         $files = array_merge($files, $arr); // merge array with files from subdirectory

    //return all found files
     return $files;

Expected result:
Alternatively, users can use preg_find ( which does not have a 50 character limitation.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-21 15:37 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

└─▪ mkdir "this is a very long directory name, which definetly exceeds 50 chars 
to test the bug"┌─[bjori][][~]
└─▪ php -r '$n = sql_regcase("this is a very long directory name, which 
definetly exceeds 50 chars to test the bug"); var_dump(glob("./$n", 
array(1) {
  [0] =>
  string(86) './this is a very long directory name, which definetly exceeds 50 
chars to test the bug'

Works fine for me?
 [2011-12-21 15:37 UTC]
-Status: Open +Status: Feedback
 [2013-02-18 00:35 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat May 15 19:01:23 2021 UTC