PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 10th, 2008, 09:01 PM
Pabs Pabs is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Canada
Posts: 100 Pabs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 52 m 22 sec
Reputation Power: 2
Relative path

this is a dumb question,..,.. I'm sure I've done this but can't seem to remember right now

I have a function that allows a user to log off.. that function is called from a number of different files.. all files are not inthe same level of directory...so how can I set the path to be dynamic?

I want to this for example

<a href="somedir/logout.php"> Log off</a>

if I call this line from a different directory it won't work for obvious reasons...what can I use to always point at the right place??

I use $_SERVER['DOCUMENT_ROOT'] in my includes and requires but it doesn't work in my <A> tag...


again...this is basic stuff and I feel stupid for asking but for some reason I can't remember/find the answer


Pabs

Reply With Quote
  #2  
Old May 11th, 2008, 12:27 AM
icandothat's Avatar
icandothat icandothat is offline
Moderator
Click here for more information.
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,551 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 2 h 55 m 16 sec
Reputation Power: 3
why doesn't it work in your a tag?
is it just because you aren't dropping into php before you use the PHP variable?
ala <?php echo $_SERVER['DOCUMENT_ROOT']; ?> or a short tag style like
<?=$_SERVER['DOCUMENT_ROOT'] ?>
__________________
There is no spoon.

Reply With Quote
  #3  
Old May 11th, 2008, 01:25 AM
cwf's Avatar
cwf cwf is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 353 cwf User rank is Private First Class (20 - 50 Reputation Level)cwf User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 3 Days 6 h 24 sec
Reputation Power: 2
The following relative URL's are relative to the address of the current page in the browser (the browser takes the path of the current page and appends the relative url to form the actual url that is requested) -

somedir/logout.php

or

./somedir/logout.php

or

../somedir/logout.php (or any combination of ../../)

The following relative URL is relative to the domain root (the browser takes the domain of the current page and appends this to form the actual url that is requested) -

/somedir/logout.php

----------------------

$_SERVER['DOCUMENT_ROOT'] is the file system path to the document root folder. It has no meaning outside of the server and putting it in a URL will result in a page not found or similar error.

Reply With Quote
  #4  
Old May 12th, 2008, 11:44 AM
Pabs Pabs is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Canada
Posts: 100 Pabs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 52 m 22 sec
Reputation Power: 2
right..... so would using SERVER_NAME be the only way?

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Relative path


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway