ecshop获取url_domain

<?php

function url_domain()
{
    $curr = strpos($_SERVER['PHP_SELF'], '/') !== false ?
            preg_replace('/(.*)()(\/?)(.)*/i', '\1', dirname($_SERVER['PHP_SELF'])) :
            dirname($_SERVER['PHP_SELF']);

    $root = str_replace('\\', '/', $curr);

    if (substr($root, -1) != '/')
    {
        $root .= '/';
    }

    return $root;
}
echo(url_domain());exit();
?>

 

posted @ 2015-05-28 10:07  李照耀  阅读(544)  评论(0编辑  收藏  举报