note 76347 deleted from reserved.variables by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: seb at omegasoft dot co dot uk 

----

More attractive way for displaying a URL

<?php

function get_url($show_port = false)
{
	if($_SERVER['HTTPS'])
	{
		$my_url = 'https://';
	}
	else
	{
		$my_url = 'http://';
	}

	$my_url .= $_SERVER['HTTP_HOST'];

	if($show_port)
	{
		$my_url .= ':' . $_SERVER['SERVER_PORT'];
	}

	$my_url .= $_SERVER['SCRIPT_NAME'];

	if($_SERVER['QUERY_STRING'] != null)
	{	
		$my_url .= '?' . $_SERVER['QUERY_STRING'];
	}

	return $my_url;
}

echo get_url(); // Outputs: http://localhost/
echo get_url(true); // Outputs: http://localhost:80/

?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.