PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

PHP Source Code


Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,350 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,490 people online right now. Registration is fast and FREE... Join Now!





Full url of the page

get full url of the page.

Submitted By:
Actions:
Rating:
Views: 35,568

Language: PHP

Last Modified: March 16, 2005
Instructions: i use for error logging, tells me what page.
use $_SERVER so it logged as superglobal.

Snippet


  1. <?
  2. $_SERVER['FULL_URL'] = 'http';
  3. if($_SERVER['HTTPS']=='on'){$_SERVER['FULL_URL'] .=  's';}
  4. $_SERVER['FULL_URL'] .=  '://';
  5. if($_SERVER['SERVER_PORT']!='80') $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
  6. else
  7. $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
  8. if($_SERVER['QUERY_STRING']>' '){$_SERVER['FULL_URL'] .=  '?'.$_SERVER['QUERY_STRING'];}
  9. ?>

Copy & Paste


Comments


silverblaze 2008-11-12 03:32:19

hey thanks for the script.. I also wanted somethin similar bt a bit diffrent. So i changed ur script a little bit. i needed to get the exact url. means i had implemented mod rewrite so the url wont be http://site.com/test.php?var1=1 bt it vl be http://site.com/test/1 so here is wht i used.. i though some1 vl get benified frm this.. :)

silverblaze 2008-11-12 03:33:00

oops.. sry i cant post the php code here. i vl make a sinplet nd paste the link .. :)

silverblaze 2008-11-12 03:39:47

http://www.dreamincode.net/code/snippet2709.htm .. here is the modified version.

jigishpthakar 2009-05-08 03:28:08

hii thanks for the above info, but its not satisfying my requirement what i need to trace is not ust url with query strin but i also need to trace #href i.e. if my url is http://jigishthakar.com/?p=2#cid then till http://jigishthakar.com/?p=2 ur code works fine but now how to trace #cid ?


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month