Jump to content


Photo

PHP and root?


Best Answer jcbones, 06 April 2013 - 05:42 PM

The $_SERVER variables hold a lot of valuable information.  The document root is one of them.

Go to the full post


  • Please log in to reply
5 replies to this topic

#1 Manixat

Manixat

    Advanced Member

  • Members
  • PipPipPip
  • 166 posts

Posted 06 April 2013 - 05:37 PM

Hello freaks,

 

 

I have been unsuccessfully trying to manage PHP to begin a path from the root directory. I have a structure like so

 

/ < ROOT

 

/Project/Public/Index.php

/Project/Public/Images/Image.png

/Project/Framework/Class.php

 

 

Index.php includes class.php which checks if image.png exists via file_exists() and does stuff. The problem is that this

 

file_exists("/Project/Public/Images/Image.png")

returns bool(false) and in order to get a bool(true) i need to start from "Images/Image.png", but then if I call the class from somewhere else this wouldn't work, I suppose?

 



#2 trq

trq

    Advanced Member

  • Administrators
  • 30,722 posts
  • LocationSydney, Australia.

Posted 06 April 2013 - 05:41 PM

Is your project really in the root of the filesystem? Seems an odd place to put it.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.


#3 jcbones

jcbones

    Advanced Member

  • Gurus
  • 2,439 posts
  • LocationNorth Carolina

Posted 06 April 2013 - 05:42 PM   Best Answer

The $_SERVER variables hold a lot of valuable information.  The document root is one of them.



#4 Manixat

Manixat

    Advanced Member

  • Members
  • PipPipPip
  • 166 posts

Posted 06 April 2013 - 05:43 PM

It is in htdocs, since I'm using xampp, to which I as well as HTML, unlike PHP, refer as root :?



#5 Manixat

Manixat

    Advanced Member

  • Members
  • PipPipPip
  • 166 posts

Posted 06 April 2013 - 05:44 PM

The $_SERVER variables hold a lot of valuable information.  The document root is one of them.

 

You mean that I need to use the absolutely absolute path even beyond the htdocs folder?

 

EDIT: I never expected I would need to go any deeper than the htdocs but that worked! Thanks :P


Edited by Manixat, 06 April 2013 - 05:45 PM.


#6 trq

trq

    Advanced Member

  • Administrators
  • 30,722 posts
  • LocationSydney, Australia.

Posted 06 April 2013 - 05:45 PM

/ is the root of the filesystem as far as php is concerned.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com