Jump to content


Photo

Need code string for "path"


  • Please log in to reply
4 replies to this topic

#1 Dhira

Dhira
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 27 March 2006 - 09:47 AM

Hi all,

simple request. I need the php code string that gives me the path in a URL.

Similar to $_SERVER[SERVER_NAME], (which gives me www.domain.com.)
I would like the code that would give me "/home/username/public_html" path (which would show the actual username).

I tried $_SERVER[PATH], - didnt work. would it have 'ROOT' in there somewhere?

#2 wildteen88

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

Posted 27 March 2006 - 10:10 AM

Try $_SERVER['DOCUMENT_ROOT'];

#3 Dhira

Dhira
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 27 March 2006 - 11:17 AM

Thanks, but that didnt work for what I'm susing it for - it might be because the file that has that code is inside another folder. Just a giess.

Is there another option that would get the "/home/username/public_html/" path if the path is being requested from within another folder?

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 27 March 2006 - 02:59 PM

Create a file with this line in it:
<?php p.hpinfo(); ?>
(remove the period between the p and h --- there is something really screwed up with the code parsing algorithms on this board)
Upload it to your server and invoke it. Look at all of the information returned and pick the one that most fits your needs. When I do it on one of the servers I use, the information I think you're looking for is contained in $_SERVER["SCRIPT_FILENAME"] and $_SERVER["PATH_TRANSLATED"]. YMMV

Ken

#5 Dhira

Dhira
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 28 March 2006 - 12:08 AM

Thanks. Those didn't work the way I wanted, but it helped me figure out what I needed.

I added a variable called:
$PathFolder = $_SERVER["DOCUMENT_ROOT"];

and I entered $PathFolder in the line where I wanted it to appear, and that worked.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users