the code
<?php
$_SERVER['QUERY_STRING'];
$text = $_SERVER['QUERY_STRING'];
$var_str = var_export($text, true);
$var = "<?php\n\n\$text = $var_str;\n\n?>";
file_put_contents('testnew.php', $var);
echo $text;
?>
what i want to do is get query-string from the url and store it in a php file testnew.php
http://test.com/query.php?asdawdawd
note i am very beginner
edit: now the get query string part is working after @tim suggestion but it still doesn't write the query-string to the file
the working code
<?php
$text = $_SERVER['QUERY_STRING'];
$file = fopen("testnew.txt","ab");
fwrite($file,$text."\n");
fclose($file);
echo $text;
?>
edit : as @tim suggested i don't need the line $_SERVER['QUERY_STRING'];
so i removed it from the code .
edit 2 : as i asked @tim about
how can i make it type in a new line like using this
fwrite($file,$text \n);
but it doesn't work
so he gave me the working one fwrite($file,$text."\n");
and i replaced the old one from the code with it fwrite($file,$text);