码迷,mamicode.com
首页 > 其他好文 > 详细

route类中检测真实的uri

时间:2015-04-19 22:32:50      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

//detect true URI, inspired bu CodeIgniter 2

    private static function detect_uri()
    {
        $uri = $_SERVER[‘REQUEST_URI‘];
        if (strpos($uri, $_SERVER[‘SCRIPT_NAME‘] === 0)) {
            $uri = substr($uri, strlen($_SERVER[‘SCRIPT_NAME‘]));
        }elseif (strpos($uri, dirname($_SERVER[‘SCRIPT_NAME‘])) === 0) {
            $uri = substr($uri, strlen(dirname($_SERVER[‘SCRIPT_NAME‘])));
        }
        if ($uri == ‘/‘ || empty($uri)) {
            return ‘/‘;
        }
        $uri = parse_url($uri, PHP_URL_PATH);
        return str_replace(array(‘//‘,‘../‘), ‘/‘, trim($uri,‘/‘));
    }

 

route类中检测真实的uri

标签:

原文地址:http://www.cnblogs.com/leezhxing/p/4440081.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!