zoukankan      html  css  js  c++  java
  • 获取URL

    // Array representing a possible record set returned from a database
    function get_url() {
        $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
        $php_self = $_SERVER['PHP_SELF'] ? safe_replace($_SERVER['PHP_SELF']) : safe_replace($_SERVER['SCRIPT_NAME']);
        $path_info = isset($_SERVER['PATH_INFO']) ? safe_replace($_SERVER['PATH_INFO']) : '';
        $relate_url = isset($_SERVER['REQUEST_URI']) ? safe_replace($_SERVER['REQUEST_URI']) : $php_self.(isset($_SERVER['QUERY_STRING']) ? '?'.safe_replace($_SERVER['QUERY_STRING']) : $path_info);
        return $sys_protocal.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '').$relate_url;
    }
     
     function safe_replace($string) {
        $string = str_replace('%20','',$string);
        $string = str_replace('%27','',$string);
        $string = str_replace('%2527','',$string);
        $string = str_replace('*','',$string);
        $string = str_replace('"','"',$string);
        $string = str_replace("'",'',$string);
        $string = str_replace('"','',$string);
        $string = str_replace(';','',$string);
        $string = str_replace('<','&lt;',$string);
        $string = str_replace('>','&gt;',$string);
        $string = str_replace("{",'',$string);
        $string = str_replace('}','',$string);
        $string = str_replace('\','',$string);
        return $string;
    }
     
    // $first_names = array_column($records, 'first_name', 'last_name');
    print_r(get_url());
  • 相关阅读:
    linux内存不足时,为了防止报错,可以使用swap
    Linux SWAP 深度解读
    tomcat启用apr需要的三个组件(缺少可能会报错)
    阿里云无法ping通解决
    linux安装jdk环境
    linux下如何彻底删除mysql
    如何让百度收录自己的网站
    [SWF]在线预览文档下载
    [C#]线程处理
    [C#]关键字
  • 原文地址:https://www.cnblogs.com/csjoz/p/7243942.html
Copyright © 2011-2022 走看看