检查查询字符串(PHP)

2 php query-string

例如,我使用查询字符串test.php?var=1.

如何检查用户之后是否输入任何内容,如同另一个字符串...

我尝试重定向到index.php,如果任何其他字符串(查询字符串)跟在我的var查询字符串后面.

有可能检查一下吗?

例如:

test.php?var=12134  (This is a good link..)
test.php?a=23&var=123 (this is a bad link, redirect to index..)
test.php?var=123132&a=23 (this is a bad link, redirect to index..)

Tom*_*igh 19

我不确定我完全理解你想要什么,但是如果你对参数的定位不感兴趣,那么这应该是有用的:

if ( isset($_GET['var']) && count($_GET) > 1 ) {
    //do something if var and another parameter is given
}
Run Code Online (Sandbox Code Playgroud)


Oll*_*ers 6

看看$_SERVER['QUERY_STRING'].