简体   繁体   中英

PHP 'QUERY_STRING' not returning anything

I'm using the following in my php code:

$file="query.txt";
$f=fopen($file,'a');
fwrite($f,"Query String:".$_SERVER['QUERY_STRING']."\n");
fclose($f);

It never returns anything. I'm simply trying to record the queried url when someone visits (ie http://example.com/index.php?q=string . Other $_SERVER fields seem to work just fine, it only seems to be the query string that doesn't work. Maybe there's something I need to setup in my .htaccess?

I'm hoping someone has an answer to how to get this to information to show.

This solved the problem:

$_SERVER['REDIRECT_QUERY_STRING']

solution from https://stackoverflow.com/a/11618256/1125006

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM