Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-05-2012, 05:02 PM   PM User | #1
keys88
New Coder

 
Join Date: Aug 2010
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
keys88 is an unknown quantity at this point
Reference in 'glob'

How would
PHP Code:
$list=glob('{../pics/*.jpg,*JPG,*jpeg}',GLOB_BRACE); 
need to be written with $_SERVER['DOCUMENT_ROOT'] in place of the relative reference?

I can't figure out those nested quote marks.

Thank you.

Last edited by keys88; 10-05-2012 at 05:09 PM.. Reason: minor typo
keys88 is offline   Reply With Quote
Old 10-05-2012, 05:30 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Not sure what you mean about the nested quote marks.
Try this:
PHP Code:
$list glob($_SERVER['DOCUMENT_ROOT'] . '/pics/*.{jpg,JPG,jpeg}'GLOB_BRACE); 
Personally I wouldn't use DOCUMENT_ROOT whenever I can avoid it; I'd use explicit relative to this file's directory.
Fou-Lu is offline   Reply With Quote
Old 10-06-2012, 12:51 AM   PM User | #3
keys88
New Coder

 
Join Date: Aug 2010
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
keys88 is an unknown quantity at this point
Thank you

Thank you.

I see I also had the open-brace in the wrong place.

I will use the relative reference.

For general knowledge: what's the drawback of using DOCUMENT_ROOT?

I thought it had the advantage of letting files be moved without changing the references.
keys88 is offline   Reply With Quote
Old 10-06-2012, 02:53 AM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
DOCUMENT_ROOT itself isn't the problem, its $_SERVER. PHP cannot guarantee anything under the $_SERVER superglobal as existing, and if you use PHP on the command line or cron jobs, than this superglobal offset isn't available.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
keys88 (10-06-2012)
Old 10-06-2012, 08:04 PM   PM User | #5
keys88
New Coder

 
Join Date: Aug 2010
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
keys88 is an unknown quantity at this point
Thank you. Very helpful.
keys88 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:56 PM.


Advertisement
Log in to turn off these ads.