作为我的第一个PHP项目之一,我正在创建一个记录用户IP地址的IP日志记录脚本.由于某种原因,我的fwrite()函数似乎没有写入我的日志文件.
有人可以帮我吗?
<?php
// IP Logger Script
// By Sam Lev
// sam@levnet.us
$iplogfile = 'iplog.txt';
$ipaddress = $_SERVER['REMOTE_ADDR'];
$webpage = $_SERVER['SCRIPT_NAME'];
$timestamp = date('m/d/Y h:i:s');
$browser = $_SERVER['HTTP_USER_AGENT'];
$fp = fopen($iplogfile, 'a+');
chmod($iplogfile, 0777);
fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$webpage.' '.$browser. "\r\n");
fclose($fp);
echo "IP ADDRESS: $ipaddress <br />\n";
echo "TIMESTAMP: $timestamp <br />\n";
echo "BROWSER: $browser <br />\n";
echo "Information logged to server. <br />\n";
?>
Run Code Online (Sandbox Code Playgroud)
运行脚本后,iplog.txt仍为空白.一切都很好.
谢谢
显然有些事情不对.#wrap的CSS没有显示出来.不知道我做错了什么.请查看下面的代码:
<html>
<head>
<title> WhateverWorks </title>
<style>
body{
background-color: #0066CC;
color: white;
}
h1{
font-size: 18pt;
color: white;
font-style: bold;
font-family: calibri;
}
#wrap{
border solid 2px #000;
background-color: #00033;
width: 800px;
height: 200px;
}
</style>
</head>
<body>
<div id="wrap">
This site is under construction...<br /> please see our facebook page for now!
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)