douzhang2092 2015-08-23 11:11
浏览 23

PHP中的多个url查询参数和if语句

I'm a beginner in PHP programming(or any other for that matter) and I'm facing a problem while trying to work on my first real world project. I have two parameters in my url, category and item, I want to use them in an if condition like this, like if they're both there, display something:

if ($_GET["category"] && $_GET["item"]) {
    echo "Success";
}

Is this even possible? I have tested the parameter values with echo outside if/elseif statements and they work. Also, if I use a single query parameter with if statement, it works.

Thanks a lot for your time. Regards.

P.S PHP version = 5.2.6.

  • 写回答

2条回答 默认 最新

  • drjgk44268 2015-08-23 11:18
    关注

    Cleanest way to do this:

    if (isset($_GET["category"],$_GET["item"]) && !empty($_GET["category"]) && !empty($_GET["item"])) {
        echo "Success";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度