wh33t Posted July 22, 2006 Share Posted July 22, 2006 Hey there, I'm sure this has been asked a few times but I cant for the life of me figure out what the problem would be called exactly.I got php running on apache, and I see now that when i do something likerequire('/inc/file.php'); my script no longer finds the file. It seems to think that the / means c:\ ... is there a way to tell Apache to work like linux? lol. Any push in the right direction would be great. Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/ Share on other sites More sharing options...
wh33t Posted July 22, 2006 Author Share Posted July 22, 2006 Ps.I dont want to have to put $_SERVER['DOCUMENT_ROOT'] everytime i wanna do an include. Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-61993 Share on other sites More sharing options...
wildteen88 Posted July 22, 2006 Share Posted July 22, 2006 Use ./ rather than /./ tells PHP to use the current working directory. Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62026 Share on other sites More sharing options...
wh33t Posted July 22, 2006 Author Share Posted July 22, 2006 Ummm, that doesn't work either. I'm trying to make it so I can reference the webroot by just using / like I could on a linux box. Is this not possible? Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62122 Share on other sites More sharing options...
wildteen88 Posted July 22, 2006 Share Posted July 22, 2006 I dont think so. I havn't seen this done. Just use relative paths. Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62131 Share on other sites More sharing options...
wh33t Posted July 22, 2006 Author Share Posted July 22, 2006 but if I include a file that includes a file relative paths dont work cause they are all relative to the file thats including them in the first place. :( Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62136 Share on other sites More sharing options...
wildteen88 Posted July 22, 2006 Share Posted July 22, 2006 This is where $_SERVER['DOCUMENT_ROOT'] comes in, if you dont want to type out $_SERVER['DOCUMENT_ROOT'] all the time then you can do this: $dr = $_SERVER['DOCUMENT_ROOT'];then use $dr to referent the document root. like so:include $dr . '/inc/file.php'; Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62139 Share on other sites More sharing options...
wh33t Posted July 22, 2006 Author Share Posted July 22, 2006 ahh. well thats what I figured I was gonna have to do unless there was some sort of command directive i could toss into apache.Ok well. if I do the documentroot thing it will run fine when i move it to the linux webspace right? Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62143 Share on other sites More sharing options...
wildteen88 Posted July 22, 2006 Share Posted July 22, 2006 Yeah it should do as $_SERVER['DOCUMENT_ROOT'] is set with the servers document root. Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62146 Share on other sites More sharing options...
wh33t Posted July 22, 2006 Author Share Posted July 22, 2006 thanks man :) appreciate that. Link to comment https://forums.phpfreaks.com/topic/15319-windows-and-absolute-paths/#findComment-62153 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.