Jump to content

glob() does not recognize "/"


ala888

Recommended Posts

The function glob() used for searching items/directories

does not recognize the root reference "/" for some reason.When I code something like

print_r(glob("/*.jpg"));

It returns all .jpgs in my C: directory(Im practicing with a desktop) rather than the specified root directory on the XXAMP

 

How do I correct this?Also is there a page anywhere that guides you on how to path with code?Like what all the "/" and stuff means, and their subsequent references to directories? I've been searching everywhere, but I dont even know what its called!

 

thanks

Link to comment
Share on other sites

On Unix-like systems, "/" is the actual root of the filesystem. Unix doesn't have drives with letters like C and D, the equivalent of the Windows C: directory on Unix is simply /. It does not refer to the web server root, it refers to the filesystem root. The web server root is in $_SERVER['DOCUMENT_ROOT'].

Link to comment
Share on other sites

Then how come, say for a linking tag for a css stylesheet, it is acceptable to state "/TEST.CSS" - and it would successfully connect with the .css document in the web server root. Rather than connecting to the file system root?

 

or is it simply a difference in the interpretation between the languages of HTML vs PHP?

like html "/" is web document, while php "/" is filesystem

Link to comment
Share on other sites

Then how come, say for a linking tag for a css stylesheet, it is acceptable to state "/TEST.CSS" - and it would successfully connect with the .css document in the web server root. Rather than connecting to the file system root?

Because the web browser and PHP are not the same thing. The browser does not have access to the filesystem on the server, it only has access to things under the web server root. PHP has access to the entire filesystem (assuming permissions are granted).
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...