/**
* 获取当前完整URL
* @return string
*/
function get_url()
{
$sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://'; //根据当前端口,判断是http还是https
$php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; //获取当前网页地址
$path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; //获取path_info信息
$relate_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $php_self . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : $path_info); //获取除域名外的完整URL,获取不到php文件(如启用了pathinfo),就获取文件实际地址和参数
$url = $sys_protocal . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . $relate_url;
return $url;
// 打印到日志
$msg = PHP_EOL . date("Y-m-d H:i:s") . " " . $url;
file_put_contents('./log.txt', $msg, FILE_APPEND | LOCK_EX);
}
$this->get_url();