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? Quote Link to comment 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. Quote Link to comment 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']; Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.