Sometimes post or get pass data we do not know what the form, it may be in JSON format or simply submitted to the data, this time we can write him into the text, we can see the data passed in what format.
$val = ""; $currentDateTime = date (' Ymdhis ', Time ()); $currentDate = date (' Ymd ', Time ()); $fileName = "ioslog/". $currentDate;//File name @ $data = fopen ($fileName, ' A + ');//Add no overwrite, first determine if the file exists, and if not, the file will be created. That is, a new file record information is created every day $val. = $currentDateTime; if ($_post) { $val. = ' | POST '. ' | '. $_post. " \ n "; foreach ($_post as $key = = $value) { $val. = ' | '. $key. ":". $value; } } else{ $val. = ' | GET '. ' | '. $_get. " \ n "; foreach ($_get as $key = = $value) { $val. = ' | '. $key. ":". $value; } } $val. = "\ n"; Fwrite ($data, $val);//write fclose ($data) in the text;
PHP post and get get data written in file