if(!isset($_GET['id']) with to different options with the same variable

前端 未结 2 1259
感动是毒
感动是毒 2021-01-29 15:36

I have this code: it works fine



        
2条回答
  •  我在风中等你
    2021-01-29 16:13

    Use in_array and add all the values you want to check against into the array:

    if(!isset($_GET['id']) || !in_array($_GET['id'], array('1000', '2000'))){
        echo 'not 1k or 2 k';
    } else {
        echo 'is 1k or 2k';
    }
    

    Functional example: https://3v4l.org/Q2uao

提交回复
热议问题