tags:

views:

69

answers:

3

how can i get the full url like:http://www.domain.com/page.php?id=someid&page=1 ? not just http://www.domain.com/page.php

+4  A: 

$_SERVER['QUERY_STRING'] has the query string portion of the url.

Amber
so PHP_SELF + QUERY_STRING should do it?
kmunky
IIRC, `$PHP_SELF` doesn't include the hostname - you'd want to add `$_SERVER['SERVER_NAME']` for that.
Amber
Why don't you just use `$_SERVER['REQUEST_URI']`, as Zied suggested?
brianreavis
+3  A: 

A quick answer:

$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
Zied
+1  A: 
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'];
Xinus
`REQUEST_URI` already has the `QUERY_STRING` appended to it.
brianreavis