preg_match('(http://.*?/)','http://news.sohu.com/s2008/reform30/',$m);
echo $m[0];

解决方案 »

  1.   

    parse_url
    专门处理此事<?Php $arrUrl=parse_url("http://news.sohu.com/s2008/reform30");
    print_r($arrUrl);//Array ( [scheme] => http [host] => news.sohu.com [path] => /s2008/reform30 )
    ?>
      

  2.   

    $_SERVER["SERVER_NAME"] 这样只能扑获到news.sohu.compreg_match('(http://.*?/)','http://news.sohu.com/s2008/reform30/',$m);
    echo $m[0];这样的方法固然好!但是我这个地址http://news.sohu.com/s2008/reform30/又如何扑获那!
      

  3.   

    试试:
    echo   'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"];
      

  4.   

    支持,用parse_url/pathinfo搞一搞