开发者

get URL in php IN INCLUDE FILE

开发者 https://www.devze.com 2023-01-31 10:59 出处:网络
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

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 adres开发者_Go百科s, 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!


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


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)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消