Strip out www

7 posts by 3 authors in: Forums > CMS Builder
Last Post: December 16, 2010   (RSS)

By Kenny - December 16, 2010

I have tried multiple ways of doing but can't seem to get it right.

I want to echo the current domain, but make sure that any "http" or "www" is stripped out. I can get the "http" out, just not the "www" with this:

<?php $domain = $_SERVER['HTTP_HOST']; echo $domain; ?>

Any suggestions?

Kenny

Re: [sagentic] Strip out www

By Jason - December 16, 2010

Hi Kenny,

Try this:

<?php $domain = str_replace("www.","",$_SERVER['HTTP_HOST']); ?>

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Strip out www

By Kenny - December 16, 2010

Hi Jason,

I tried that and it returns nothing.

I viewed the source of the output and nothing is there either.

Kenny

Re: [sagentic] Strip out www

By Jason - December 16, 2010 - edited: December 16, 2010

Hi Kenny,

Did you add an echo statement?

<?php $domain = str_replace("www.","",$_SERVER['HTTP_HOST']);

echo $domain;
?>

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Strip out www

By zip222 - December 16, 2010

remove the $ in front of "echo"

Re: [zip222] Strip out www

By Jason - December 16, 2010

Good catch. Thanks!
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/