0

i have some problem i try to get the uri in php.

I'm using:

 $_SERVER['REQUEST_URI']

It works just fine if i do it in the index.php, but, i NEED to get the url in a include file, but, when i do it, it takes the FILE adress, i mean, it shows something like this

adress bar: www.webpage.com/index.php

$_SERVER['REQUEST_URI'] output: webpage/includefile.php

I am explaining myself here? Thanks!

1
  • Could you give us some context? How are you using this code? and How are you including it into the page? Commented Dec 18, 2010 at 23:06

3 Answers 3

1

How are you including the file? If it's being included via an HTTP reference then it's actually being served as a page and the functionality you are seeing is correct. If the include path is a local file, you shouldn't be seeing this behaviour

Sign up to request clarification or add additional context in comments.

Comments

1

Found this whilst trying to solve the same issue. My solution that worked is to use $_SERVER['HTTP_REFERER'] This worked well in that it also included the parameters (e.g. ?this=that&foo=bar)

Comments

0

Maybe somewhere in your code (or in another include file) the value is overwritten.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.