从URL-string [重复]获取网站名称

This question already has an answer here:

I haven URL-string like http://www.google.com/recaptcha/api/img/clean/logo.png, how can I extract only google.com from the URL? I want to do this on all my URL-strings.

</div>

Try function parse_url()

<?php
$url =  'http://www.google.com/recaptcha/api/img/clean/logo.png';
$array = parse_url($url);

echo $array['host'];
<?php    
echo $_SERVER['SERVER_NAME'];
?>