我有这个网址:
localhost/moked/insert_event.php?custnumber=1234&event=E15&port=8088&areanumber=17
我想检查用户是否已将其更改为例如:
localhost/moked/insert_event.php?custnumber=1234
我知道如何检查变量是否为空,但我想知道用户是否已经取出参数.我怎样才能做到这一点?
要为单个变量执行此操作非常简单:
if (!isset($_GET['event'])) {
// event is missing
}
Run Code Online (Sandbox Code Playgroud)
大多数人不知道的是,该isset命令将采用您需要的尽可能多的参数.您可以一次检查所有必需的参数:
if (isset($_GET['custnumber'], $_GET['event'], $_GET['port'], $_GET['areanumber'])) {
// all parameters are set
} else {
// some are missing
}
Run Code Online (Sandbox Code Playgroud)