The number 1 corresponds to GLOB_ERR , which was added in PHP 5.1.0 (see Changelog) . If you get this error, you are using an outdated version of PHP.
Consider upgrading to a version that is not End of Life.
Please note that you will also get this error if you used a constant in the first place. PHP doesn't care if you use a flag name or value. As you can see from OPCodes, PHP will still send the value to glob :
Code: glob('foo', GLOB_ERR); Finding entry points Branch analysis from position: 0 Jump found. Position 1 = -2 filename: /in/n0vqf function name: (null) number of ops: 4 compiled vars: none line
The reason you want to use a constant is because it is more readable than a magic number . In addition, relying on a constant, it is more stable if the value changes for some technical reason.
This code can be used to get the GLOB_* constants:
foreach (get_defined_constants() as $k => $v) { if (strpos($k, "GLOB") === 0) { echo "$k => $v", PHP_EOL; } }
Exit (PHP 5.6.15):
GLOB_BRACE => 1024 GLOB_MARK => 2 GLOB_NOSORT => 4 GLOB_NOCHECK => 16 GLOB_NOESCAPE => 64 GLOB_ERR => 1 GLOB_ONLYDIR => 8192 GLOB_AVAILABLE_FLAGS => 9303
For more information, see the glob implementation in
Gordon Nov 13 '15 at 8:46 2015-11-13 08:46
source share