Code Snippets

  

PHP Source Code


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

Join 149,255 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,261 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: 28,405

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.


Add comment


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




Be Social

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

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month