简体   繁体   中英

Echo Query Without “q=/index.php”?

Right now I'm using $_SERVER['QUERY_STRING'] to echo the query on the page and for it ended up looking like this:

q=/index.php&utm_domain=

I'm not sure why the q=/index.php part is appearing, but I just want it to display utm_domain=

I also tried

http_build_query($_GET)

but I have no idea why this is happening since I haven't seen it before.. how do i fix this so it displays only the query?

Seems like you've got some URL rewriting or similar that sets the q parameter to the original request.

You can easily filter out the q parameter when displaying the query string. For example

$query = http_build_query(array_filter($_GET, function($key) {
    return $key !== 'q';
}, ARRAY_FILTER_USE_KEY));

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