isset $ _GET多值

时间:2016-11-12 07:32:58

标签: php mysql

我正在尝试检查是否设置了两个GET参数,但我的if语句未正确检查。我做错了什么?

 if(isset($_GET['eventTitle'] && $_GET['eventID'])) {
    $eventT = $_GET["eventTitle"];      
    $eID = $_GET["eventID"]; //get event id     
 }

我应该如何检查是否设置了多个$ _GET参数?

3 个答案:

答案 0 :(得分:1)

if(isset($_GET['eventTitle']) && isset($_GET['eventID'])) {        
    $eventT = $_GET["eventTitle"];       
    $eID    = $_GET["eventID"]; //get event 
}

答案 1 :(得分:1)

按照以下方式执行

if(isset($_GET['eventTitle']) && isset($_GET['eventID'])){ 

}

答案 2 :(得分:0)

$eventTitle = isset($_GET['eventTitle']) ? $_GET['eventTitle'] : '';
$eventId = isset($_GET['eventId']) ? $_GET['eventId'] : ''; // or : 0 ; better use eventId instead eventID 
//Also better place this top of the block, so you can reuse them without $_GETs



if ($eventTitle && $eventId) {
    // your code here
}