$query = rtrim($_SERVER['QUERY_STRING'], '/');
$params = explode('&', $query);
// test.loc/?var1=1&var2=2
Array
(
[0] => var1=1
[1] => var2=2
)
// test.loc/var1=1?var2=2
Array
(
[0] => var1=1
[1] => var2=2
)
test.loc/var1=1?var2=2
$query = rtrim($_SERVER['QUERY_STRING'], '/');
$params = explode('&', $query);
// $query
var1=1&var2=2
// $params
Array
(
[0] => var1=1
[1] => var2=2
)