note 79565 deleted from reserved.variables by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:28:47 +0000 |
| Subject: | note 79565 deleted from reserved.variables by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134374@lists.php.net to get a copy of this message | ||
Note Submitter: Christian J. Kiewiet
----
The get_url() function below a bit smaller and a slight bit improved, yet much uglier.
<?php
function get_url($show_port = false)
{
$protocol = ($_SERVER['HTTPS']) ? 'https://' :
'http://';
$host = $_SERVER['HTTP_HOST'];
$port = ($show_port || $_SERVER['SERVER_PORT']!=80) ?
":{$_SERVER['SERVER_PORT']}" : '';
$file = $_SERVER['SCRIPT_NAME'];
$query = ($_SERVER['QUERY_STRING']) ?
"?{$_SERVER['QUERY_STRING']}";
return $protocol.$host.$port.$file.$query;
}
?>