|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
|||
|
|||
|
right..... so would using SERVER_NAME be the only way?
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Relative path |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|