[php] show url on page

  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Joined: Mar 20, 2004
  • Posts: 401
  • Loc: Scorpion Hole
  • Status: Offline

Post February 11th, 2005, 2:22 pm

http://sc0rp.ath.cx/test/get.php?id=a;l ... test5=asdf
That is this script exactly.
PHP Code: [ Select ]
<?php
 
$url = $_SERVER[HTTP_HOST] . $_SERVER[PHP_SELF] . "?";
 
$i = 0;
 
foreach($_GET as $k=>$v) {
 
    $url .= $k . "=" . $v;
 
    if($i < count($_GET)-1)
 
        $url .= "&";
 
    $i++;
 
}
 
echo "<a href=\"http://" . $url . "\">http://" . $url . "</a>";
 
?>
  1. <?php
  2.  
  3. $url = $_SERVER[HTTP_HOST] . $_SERVER[PHP_SELF] . "?";
  4.  
  5. $i = 0;
  6.  
  7. foreach($_GET as $k=>$v) {
  8.  
  9.     $url .= $k . "=" . $v;
  10.  
  11.     if($i < count($_GET)-1)
  12.  
  13.         $url .= "&";
  14.  
  15.     $i++;
  16.  
  17. }
  18.  
  19. echo "<a href=\"http://" . $url . "\">http://" . $url . "</a>";
  20.  
  21. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 11th, 2005, 2:22 pm

  • BartAfterDark
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 21, 2004
  • Posts: 120
  • Status: Offline

Post February 11th, 2005, 2:33 pm

Scorpius wrote:
http://sc0rp.ath.cx/test/get.php?id=a;lfkj&test=adf;&test5=asdf
That is this script exactly.
PHP Code: [ Select ]
<?php
$url = $_SERVER[HTTP_HOST] . $_SERVER[PHP_SELF] . "?";
$i = 0;
foreach($_GET as $k=>$v) {
    $url .= $k . "=" . $v;
    if($i < count($_GET)-1)
        $url .= "&";
    $i++;
}
echo "<a href="http://" . $url . "">http://" . $url . "</a>";
?>
  1. <?php
  2. $url = $_SERVER[HTTP_HOST] . $_SERVER[PHP_SELF] . "?";
  3. $i = 0;
  4. foreach($_GET as $k=>$v) {
  5.     $url .= $k . "=" . $v;
  6.     if($i < count($_GET)-1)
  7.         $url .= "&";
  8.     $i++;
  9. }
  10. echo "<a href="http://" . $url . "">http://" . $url . "</a>";
  11. ?>


I love you :D :D :D
  • darkermoon
  • Expert
  • Expert
  • User avatar
  • Joined: May 17, 2004
  • Posts: 542
  • Loc: Riverdale, MD
  • Status: Offline

Post February 11th, 2005, 11:23 pm

I could do this but, it's always really late at night when I'm on here and my brain's fried from hours of PHP. What I think would be good for you is to learn PHP so you know what the script actually does and understand how code is written rather than solely depending on people to do it for you.

//EDIT: see your problem is resolved. congrats.
  • Jacob Marshall
  • Born
  • Born
  • No Avatar
  • Joined: Oct 03, 2009
  • Posts: 2
  • Status: Offline

Post October 4th, 2009, 12:05 am

Code: [ Select ]
<?php
$url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
echo "<a href='$url'>$url</a>";
?>
  1. <?php
  2. $url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
  3. echo "<a href='$url'>$url</a>";
  4. ?>


That works!

Post Information

  • Total Posts in this topic: 19 posts
  • Users browsing this forum: Bigwebmaster and 203 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.