PHP 记录请求路径地址

$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on"){
	$pageURL .= "s";
}
$pageURL .= "://";
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
if ($_SERVER["SERVER_PORT"] != "80") { 
	$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; 
} else { 
	$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; 
}
$logstr = $pageURL."\n";
$name = date("Ymd");    
$filename = "/tmp/str-".$name.".log";
$fh = fopen($filename, "a");
fwrite($fh, $logstr);
fclose($fh);

 

你可能感兴趣的:(PHP)