PHP获取当前页面完整URL地址

/**
 * 获取当前页面完整URL地址
 */
function get_url() {
    $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
    $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    $path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
    $relate_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $php_self . (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : $path_info);
    $relate_url = $sys_protocal . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . $relate_url;
    return urlencode($relate_url);

}



二当家的官网,请访问 http://www.erdangjiade.com

更多商城企业源码,尽在 http://www.erdangjiade.com/source

更多原创模板,尽在 http://www.erdangjiade.com/templates  

网页特效下载:www.erdangjiade.com/js

PHP/Mysql:www.erdangjiade.com/php
     
PHP网站开发求职QQ群 368848856

上一篇:eclipse中Server Locations选项


下一篇:10年编程无师自通