Helping ordinary people create extraordinary websites!
   

PHP get current page's URL

Wednesday, 18th November 2009
by Millie

How can I get the URL of the current page I am on using PHP?




Tags:

Brady
Hey Millie,
I use the following code and it does the trick for me:

$current_url= (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

I hope this helps.



Monday, 7th December 2009
Votes:
13
8

More PHP Help:
» Creating new login in php
» Show me the syntax for the months of the year and the number of days in each month output to the screen in php?
» How to ping Google when sitemap is updated?
» How to do a new line or linebreak in a textarea field with PHP?
» PHP Includes, how to add page data to other pages using PHP include?
» Where can I find a script that can be used to export mysql database to dbf database?
» How to get database values in table format on form?
» How to add RSS feeds into my web page with PHP?