Skip to content Skip to sidebar Skip to footer

How Do I Capture The Whole Url Using Php?

I would like to the whole of the URL including the _GET variable names and values, for example www.mywebsite.com/store.php?department=MENS The code I have used below only gives me

Solution 1:

try this function

publicfunctiongetURL()
     {
        $protocol = @$_SERVER['HTTPS'] == 'on' ? 'https' : 'http';

        return$protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     }

taken from [this article I wrote][1]

use it like

echo getURL();

see if works for you [1]: http://jaspreetchahal.org/how-do-you-get-current-browser-url-with-php/

Solution 2:

like this one..

$(function() {
$('.ajax-link').click( function() {
var link=$(this).attr('href');
     $.post( "savedl.php",{name:link}, 
     function(data) {
        window.location.href=link;
     });
     returnfalse; // don't follow the link!

  });
});

sample is i have the url in the link

<a href='' class="ajax-link"id="url_name">url </a>

then you can get the value on savedl.php using $_POST['name']

Post a Comment for "How Do I Capture The Whole Url Using Php?"