$value) { $out[] = $key.'='.$value; } // write the log line $cookie = implode("&", $out); } else { $cookie = ''; } // add GET info if (count($_GET)) { $out = []; foreach ($_GET as $key => $value) { $out[] = $key.'='.$value; } $get_info = '?'.implode("&", $out); } else { $get_info = ''; } // write the log line file_put_contents($fname, $prefix . $get_info . "\t" . $cookie . "\n", FILE_APPEND); // add POST info if (count($_POST)) { $out = []; foreach ($_POST as $key => $value) { $out[] = $key.'='.$value; } // write the log line file_put_contents($fname, "[POSTDATA] " . implode("&", $out) . "\n", FILE_APPEND); } } return true; } catch (\Exception $e) { // we shouldn't raise exceptions if we can't log for some reason // but we definitelly should return false return false; } } }