【问题标题】:Multiple isset's on PHPPHP 上的多个 isset
【发布时间】:2019-11-20 07:05:15
【问题描述】:

我如何获得 ISSET 搜索,例如通过添加 id 和 weight,或使用 JSON 仅添加 id?

例如 example.php?tag=id=3343&weight=alot

<?php 

header('Content-Type: application/json');

$tags= array();

$data = (object) [];
$data->id= "3343";
$data->weight= "alot";
$data->year= 42;
array_push( $data);

if( isset( $_GET['tag'])){
    echo json_encode($tags);
}
?>

【问题讨论】:

  • 你想通过检查来遍历所有的 URL 参数键吗?
  • 如果可以列出所有 42 岁以上且重量很大的物品,或者只提供一个参数,如果这有意义的话。

标签: php json get isset


【解决方案1】:

isset 的函数可以带多个参数,你可以这样改变:

if( isset( $_GET['tag'],$_GET['weight'], ... ))
{
echo json_encode($tags);
}

我希望这是你想要的。

【讨论】:

  • 那么 url 是什么?标签=某物&重量=某物?谢谢。
  • 你的域名应该是“?”并在变量“&”之间使用。像这样:www.yoursite.com?myparam1=123&myparam2=abc
  • 你的网址应该是 example.php?id=213&tag=3343&weight=alot
猜你喜欢
  • 1970-01-01
  • 2013-01-06
  • 2017-04-10
  • 2023-03-24
  • 2019-09-22
  • 2012-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多