Manixat Posted April 6, 2013 Share Posted April 6, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/276627-php-and-root/ Share on other sites More sharing options...
trq Posted April 6, 2013 Share Posted April 6, 2013 Is your project really in the root of the filesystem? Seems an odd place to put it. Quote Link to comment https://forums.phpfreaks.com/topic/276627-php-and-root/#findComment-1423338 Share on other sites More sharing options...
Solution jcbones Posted April 6, 2013 Solution Share Posted April 6, 2013 The $_SERVER variables hold a lot of valuable information. The document root is one of them. Quote Link to comment https://forums.phpfreaks.com/topic/276627-php-and-root/#findComment-1423340 Share on other sites More sharing options...
Manixat Posted April 6, 2013 Author Share Posted April 6, 2013 It is in htdocs, since I'm using xampp, to which I as well as HTML, unlike PHP, refer as root :? Quote Link to comment https://forums.phpfreaks.com/topic/276627-php-and-root/#findComment-1423341 Share on other sites More sharing options...
Manixat Posted April 6, 2013 Author Share Posted April 6, 2013 (edited) 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 Edited April 6, 2013 by Manixat Quote Link to comment https://forums.phpfreaks.com/topic/276627-php-and-root/#findComment-1423342 Share on other sites More sharing options...
trq Posted April 6, 2013 Share Posted April 6, 2013 / is the root of the filesystem as far as php is concerned. Quote Link to comment https://forums.phpfreaks.com/topic/276627-php-and-root/#findComment-1423343 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.