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());
  • 相关阅读:
    [CQOI2007]涂色
    NOI.AC NOIP模拟赛 第五场 游记
    AGC018D Tree and Hamilton Path
    AGC001E BBQ Hard
    LOJ6089 小Y的背包计数问题
    UOJ272 【清华集训2016】石家庄的工人阶级队伍比较坚强
    Gym102538A Airplane Cliques
    AT5762 Preserve Diameter
    CF1030G Linear Congruential Generator
    CF1149E Election Promises
  • 原文地址:https://www.cnblogs.com/csjoz/p/7243942.html
Copyright © 2011-2022 走看看