Muffy Posted April 4, 2007 Share Posted April 4, 2007 Is it possible to use PHP to grab URL of the current page and put in into a variable? ie. If I'm viewing: http://localhost/mypage/index?article=23 Can I put "http://localhost/mypage/index?article=23" into a variable? Link to comment https://forums.phpfreaks.com/topic/45597-solved-get-url/ Share on other sites More sharing options...
Caesar Posted April 4, 2007 Share Posted April 4, 2007 Yes. <?php $current = $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; ?> Also a few other ways to do it. Link to comment https://forums.phpfreaks.com/topic/45597-solved-get-url/#findComment-221407 Share on other sites More sharing options...
hitman6003 Posted April 4, 2007 Share Posted April 4, 2007 or... echo $_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING']; Link to comment https://forums.phpfreaks.com/topic/45597-solved-get-url/#findComment-221409 Share on other sites More sharing options...
Muffy Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks guys that exactly what I'm after. Link to comment https://forums.phpfreaks.com/topic/45597-solved-get-url/#findComment-221798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.