I’m trying to create a log file that contains some infotmation, my code is,
$info = date("Y-m-d H:i:s")." ".$_SERVER['REMOTE_ADDR']." ".$_SERVER['REQUEST_METHOD']." ".$_SERVER['REQUEST_URI']." ".$_SERVER['HTTP_REFERER']."\n".$_POST."\n";
$req_dump = print_r($info, TRUE);
$fp = fopen('request.log', 'a');
fwrite($fp, $req_dump);
fclose($fp);
the code logs the information like this,
2013-01-15 17:10:15 192.168.0.50 POST /index.php http://www.domain.com/article/12
Array
the $_POST value is array and no values are being dumped.
How to correct this and get the $_POST values logged?
Thanks in advance
You are just appending
$_POSTto your string. That converts it to the word"Array", because that’s how Array -> String conversions work.You want to
print_rthe$_POSTarray, not the concatenated string.