Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] How to find the full path of curent page?


[SOLVED] How to find the full path of curent page?

Reply
  #1 (permalink)  
Old 09-05-05, 04:49 PM
adrianTNT's Avatar
adrianTNT adrianTNT is offline
New Member
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] How to find the full path of curent page?

I am trying to use the current page path in a script, for example if you have the script in the file www.page.com/products.php a code in this page should return the page path: "www.page.com/products.php".

I used:
PHP Code:

echo ($_SERVER['REQUEST_URI']); 

But I need to use this code in a header so the return path is not full page path but my header path, the header path is posted in all my pages by "include", I need other function to do the same thing but to return complete string from my browser's address bar, not just the link in my header where this code block is located.

Can anyone help?
Thank you.

-Adrian.
Reply With Quote
  #2 (permalink)  
Old 09-05-05, 10:40 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
Well it would probably be best to just define a variable and concat what you need.

PHP Code:

$domain 'www.page.com';

$redirection $domain.$_SERVER['REQUEST_URI']; 
However you might be able to use $_SERVER['HTTP_HOST'] to get what you want, it's just not guranteed to be accurate.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #3 (permalink)  
Old 09-07-05, 11:44 AM
adrianTNT's Avatar
adrianTNT adrianTNT is offline
New Member
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I am not sure how to explain, the above did exactley what my code did and both work only in some situations:

I have one main file (x2.php) that loads the code by include but with FULL path:

PHP Code:

include('http://www.adriantnt.com/x.php'); 

in x.php (the included file) I have:
PHP Code:

$domain 'www.adriantnt.com'
echo(
$domain.$_SERVER['REQUEST_URI']); 
So when I access www.adriantnt.com/x2.php which has x1 in it I get:
"www.adriantnt.com/x.php"
And what I want to get is the file I typed in address bar, x2.php not x.php
The code displays the corect path if at include I type a relative path like:
PHP Code:

include('x.php'); 

But all my site is made to include the files with full path:
PHP Code:

include('http://www.adriantnt.com/x.php'); 

Is there a way or a function to return the parent file name or its path? in this case name is x2.php

Thank you.
-Adrian.
Reply With Quote
  #4 (permalink)  
Old 09-07-05, 03:21 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
I'm sure there is a solution to your problem, but perhaps you should look at it a different way. I can't think of an application where you would need to do this.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #5 (permalink)  
Old 09-07-05, 05:43 PM
adrianTNT's Avatar
adrianTNT adrianTNT is offline
New Member
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
For waht I need it:

Google has a service that translates web pages, something like this:

http://translate.google.com/translat...language_tools

I want ot place this link in my headers, for example it will say "translate into German", but that link should tell google what link to translate so I need a php code that returns path.

My PHP script can find curent page path only if the included file (header) was included by include('header.php') if I use
include('http://www.adriantnt.com/header.php') then it says that curent path is my header not the full page.
So how to use include code? Is it incorect to point to a file like this? http://www.adriantnt.com/header.php ? Do I have to use header.php or something like home/www/header.php ?

What is the corect use of include?
Eventually I will just change paths to my header so it works but maybe I can fing a better solution to return curent page path.
Reply With Quote
  #6 (permalink)  
Old 09-07-05, 06:14 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Where is the little smilie with the head spinning on it's shoulders and beating itself silly with a hammer?
Reply With Quote
  #7 (permalink)  
Old 06-09-08, 09:11 AM
adrianTNT's Avatar
adrianTNT adrianTNT is offline
New Member
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I was reading this 3 years old post and I am now thinking...
What the heck was I tring to do there ?! )
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
drop down for curent links on page..... prodigy Script Requests 0 01-25-05 01:02 PM
page browsing problem mivec PHP 3 04-17-04 03:43 AM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM
Display full size image from thumb without page reloading borgo JavaScript 5 08-12-03 02:30 AM


All times are GMT -5. The time now is 06:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.