[英]PHP GET catch all
Using the GET protocol with php I can get data passed to my program. 使用GET协议和php可以将数据传递到我的程序。 With something like
$_GET["fname"];
用类似
$_GET["fname"];
. 。
What I'm wondering is there any way to make some sort of a catch all. 我想知道的是,有什么办法可以使一切都变得成功。 Where I did not need to know the var name before runtime?
在运行时之前我不需要知道var名称的地方?
It's just an associative array, handle it like any other: 它只是一个关联数组,像处理其他数组一样处理它:
foreach ($_GET as $name => $value) {
echo "$name: $value\n";
}
If you just want "the first" value or "the one" value, do: 如果只需要“第一个”值或“一个”值,请执行以下操作:
$value = current($_GET);
You can also pull items out of $_GET
like this: 您也可以像这样从
$_GET
取出项目:
$var = 'fname';
$fname = $_GET[$var];
You can pull multiple items like this: 您可以像这样拉出多个项目:
foreach(array('fname', 'lname') as $var) {
echo $var.' = '.$_GET[$var].'<br>;
}
Is this what you meant? 这是你的意思吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.