Jump to content


Photo

Windows and absolute paths?


  • Please log in to reply
9 replies to this topic

#1 wh33t

wh33t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 22 July 2006 - 08:07 AM

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 like

require('/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.

#2 wh33t

wh33t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 22 July 2006 - 08:09 AM

Ps.

I dont want to have to put $_SERVER['DOCUMENT_ROOT'] everytime i wanna do an include.

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 July 2006 - 11:50 AM

Use ./ rather than /

./ tells PHP to use the current working directory.

#4 wh33t

wh33t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 22 July 2006 - 06:05 PM

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?

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 July 2006 - 06:24 PM

I dont think so. I havn't seen this done. Just use relative paths.

#6 wh33t

wh33t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 22 July 2006 - 06:30 PM

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. :(

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 July 2006 - 06:36 PM

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';

#8 wh33t

wh33t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 22 July 2006 - 06:41 PM

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?

#9 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 July 2006 - 06:45 PM

Yeah it should do as $_SERVER['DOCUMENT_ROOT'] is set with the servers document root.

#10 wh33t

wh33t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 22 July 2006 - 07:10 PM

thanks man :) appreciate that.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users