我正在尝试REQUEST
使用此脚本捕获所有数据并保存到文本文件:
<?php
$blocked = array('submit');
$list = null;
$data = date("G:i - D.M.Y");
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$IPsrv = $_SERVER['REMOTE_ADDR'];
foreach($_REQUEST as $field_name => $field_value) {
if(!in_array($field_name, $blocked))
$list .= "{$field_name} : {$field_value}\n";
}
$list = rtrim($list, "\n");
$fp = fopen("../data.txt", 'a');
fwrite($fp, "
================================
$list
================================");
fclose($fp);
?>
代码有效,但我有一个问题,data.txt
文件没有正确保存,我有更多NULL
字符。怎样才能解决这个问题?