检查查询字符串 (PHP) [英] Check query string (PHP)
本文介绍了检查查询字符串 (PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用查询字符串,例如 test.php?var=1
.
如何检查用户是否在此之后输入了任何内容,例如另一个字符串...
如果我的 var
查询字符串后面有任何其他字符串(查询字符串),我尝试重定向到 index.php.
可以检查一下吗?
例如:
<前>test.php?var=12134(这是一个很好的链接..)test.php?a=23&var=123(这是一个坏链接,重定向到索引..)test.php?var=123132&a=23(这是一个坏链接,重定向到索引..) 解决方案
我不确定我是否完全理解你想要什么,但如果你对参数的定位不感兴趣,这应该可行:
if ( isset($_GET['var']) && count($_GET) > 1 ) {//如果给定了var和另一个参数,则做一些事情}
I use a query string, for example test.php?var=1
.
How can I check if a user types anything after that, like another string...
I try to redirect to index.php if any other string (query string) follows my var
query string.
Is it possible to check this?
For example:
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..)
解决方案
I'm not sure I fully understand what you want, but if you're not interested in the positioning of the parameters this should work:
if ( isset($_GET['var']) && count($_GET) > 1 ) {
//do something if var and another parameter is given
}
这篇关于检查查询字符串 (PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文