php.ini
error_log = syslog
修改为自己的路径
error_log = D:\error\error.log
<?php
ini_set('display_errors', 'off');
ini_set('error_log','D:\error\testError.log');
error_reporting(-1);
echo $test;
echo "<hr/>";
settype($var, 'king');
echo "<hr/>";
test();
?>
Paste_Image.png
Paste_Image.png
test.php
<html>
<head>
<title></title>
</head>
<body>
<h1>登陆界面</h1>
<form action="doAction.php" method="post">
用户名:<input type="text" name="username" id=""/></br/>
密码:<input type="password" name="password" id=""/><br/>
<input type="submit" value="登陆">
</form>
</body>
</html>
doAction.php
<?php
//不显示错误
ini_set('display_errors', 0);
ini_set('date.timezone', 'PRC');
//报告所有错误
error_reporting(-1);
ini_set('log_errors', 1);
ini_set('error_log', 'D:\error\adminLogin.log');
ini_set('ignore_repeated_errors', 'on');
ini_set('ignore_repeated_source', 'on');
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == 'admin' && $password == 'admin') {
echo "登陆成功";
} else {
$date = date("T-m-d H:i:s", time());
$ip = $_SERVER['REMOTE_ADDR'];
$message = "用户{$username}在{$date}以密码$password}尝试登陆系统!IP地址为{$ip}";
error_log($message);
header('location:test.php');
}
?>
Paste_Image.png
网友评论