Jump to content

Retrieve a whole URL via GET (or is there a better way?)


closet geek

Recommended Posts

[code]<?php
function get_id($url){
$end = $url;
$begin = $_SERVER['SCRIPT_NAME'];
$var1 = str_replace($begin,'',$end);
$var2 = str_replace('?id=','',$var1);
return $var2;
}
echo 'http://'.get_id($_SERVER['REQUEST_URI']);
?>[/code]

http://tzfiles.com/phpcode/entities.php?id=d-top.org/display.php?artist=orgy
[quote author=The Little Guy link=topic=116598.msg475304#msg475304 date=1164746628]
[code]<?php
function get_id($url){
$end = $url;
$begin = $_SERVER['SCRIPT_NAME'];
$var1 = str_replace($begin,'',$end);
$var2 = str_replace('?id=','',$var1);
return $var2;
}
echo 'http://'.get_id($_SERVER['REQUEST_URI']);
?>[/code]

http://tzfiles.com/phpcode/entities.php?id=d-top.org/display.php?artist=orgy
[/quote]

Thank you so much! I slightly adapted what you posted just then, for anyone who comes across this thread in the future this is the code I ended up using to get the behaviour I wanted:

[code]
<?php
function get_id($url){
       $end = $url;
       $begin = $_SERVER['SCRIPT_NAME'];
       $var1 = str_replace($begin,'',$end);
       $var2 = str_replace('/transfer=','',$var1);
       return $var2;
}
$myvar = get_id($_SERVER['REQUEST_URI']);
?>  
[/code]

cg :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.