emartin24 Posted August 31, 2007 Share Posted August 31, 2007 Hello, I can't seem to get the GLOB_BRACE flag to work on windows (Apache2.2/PHP5.2.1). I've tried all of the following and nothing works (the variations are with / vs \\ and ' vs "): <?php print_r(glob("{C:/Apache2.2/htdocs/webapp/system/,C:/Apache2.2/htdocs/webapp/application/}config/log.php",GLOB_BRACE)); print_r(glob('{C:/Apache2.2/htdocs/webapp/system/,C:/Apache2.2/htdocs/webapp/application/}config/log.php',GLOB_BRACE)); print_r(glob("{C:\\Apache2.2\\htdocs\\webapp\\system\\,C:\\Apache2.2\\htdocs\\webapp\\application\\}config\\log.php",GLOB_BRACE)); print_r(glob("{C:/Apache2.2/htdocs/webapp/system,C:/Apache2.2/htdocs/webapp/application}/config/log.php",GLOB_BRACE)); print_r(glob('{C:/Apache2.2/htdocs/webapp/system,C:/Apache2.2/htdocs/webapp/application}/config/log.php',GLOB_BRACE)); print_r(glob("{C:\\Apache2.2\\htdocs\\webapp\\system,C:\\Apache2.2\\htdocs\\webapp\\application}\\config\\log.php",GLOB_BRACE)); ?> If I take out the GLOB_BRACE and specify the direct path, it does work: <?php print_r(glob("C:\\Apache2.2\\htdocs\\webapp\\application\\config\\log.php")); print_r(glob("C:/Apache2.2/htdocs/webapp/application/config/log.php")); print_r(glob('C:/Apache2.2/htdocs/webapp/application/config/log.php')); ?> Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/ Share on other sites More sharing options...
lemmin Posted August 31, 2007 Share Posted August 31, 2007 Why are you ending the brace before the end of the address? I am pretty sure that is why it isn't working. Have you tried: print_r(glob("{C:/Apache2.2/htdocs/webapp/system/,C:/Apache2.2/htdocs/webapp/application/config/log.php}",GLOB_BRACE)); Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338664 Share on other sites More sharing options...
emartin24 Posted August 31, 2007 Author Share Posted August 31, 2007 Why are you ending the brace before the end of the address? I am pretty sure that is why it isn't working. The brace comes before the end because I'm looking for config/log.php and it could be in either one of those directories. There may be a log.php elsewhere, but I only want it if it exists in either of those 2 paths. Hopefully that makes sense... Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338669 Share on other sites More sharing options...
lemmin Posted August 31, 2007 Share Posted August 31, 2007 So why don't you do: print_r(glob("{C:/Apache2.2/htdocs/webapp/system/config/log.php,C:/Apache2.2/htdocs/webapp/application/config/log.php}",GLOB_BRACE)); Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338675 Share on other sites More sharing options...
emartin24 Posted August 31, 2007 Author Share Posted August 31, 2007 Well...because it's part of a method that takes in parameters to create the pattern: glob($paths.$search.EXT, GLOB_BRACE + GLOB_NOSORT) There probably are a lot of ways to work around the problem, but I found it interesting that in this case, the GLOB_BRACE flag seems to break things on windows. The same call works on linux (with different paths of course). Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338692 Share on other sites More sharing options...
emartin24 Posted August 31, 2007 Author Share Posted August 31, 2007 I think I've narrowed it down to the issue being caused by the colon ( in the braces...I'm guessing that is causing the pattern match to fail. Maybe I'll submit a PHP bug and see what they say... Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338732 Share on other sites More sharing options...
lemmin Posted August 31, 2007 Share Posted August 31, 2007 If it works on linux it isn't a PHP bug. I would guess that the reason it works on Linux and not Windows is because of the filesystems being different. I think Windows differentiates between files and directories more so than Linux. When you end the braces early, it probably looks for "config/log.php" as a file in that directory. In Windows it probably doesn't work because of how it discerns between the directory and file, but in Linux, it is probably just added to the address. Maybe not. Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338739 Share on other sites More sharing options...
emartin24 Posted August 31, 2007 Author Share Posted August 31, 2007 Well...it works in linux because linux does not use colons in the path names. The fact that glob can't handle windows paths in braces, seems to be to be a bug. But...I'll let them determine that Here's a link to the but report so you can see the test case I ran. If I moved the part of the string that contains the colon out of the braces, it works. http://bugs.php.net/bug.php?id=42501 It will probably just require a different solution...but there definitely is an issue with GLOB_BRACE and colons. Thanks for the help... Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338748 Share on other sites More sharing options...
lemmin Posted August 31, 2007 Share Posted August 31, 2007 You could test this by having multiple directories extending the one your php is in. You could make the exact same tree of folders from that directory and you wouldn't need to include colons in the glob string. Quote Link to comment https://forums.phpfreaks.com/topic/67459-glob-windows-and-glob_brace-issue/#findComment-338753 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.