let say you have a script and and you want to know the current domain name but if the hostname is not on the url then add it.

for example, i want to force http://wallpaperama.com to be http://www.wallpaperama.com

i can use this

<?
$domainname = $_SERVER['HTTP_HOST'];
if(!strstr($domainname,'www.')){
$domainname = str_replace('www.','',$string);
}
?>