in_array的三个参数

needle
待搜索的值。

haystack
待搜索的数组。

strict
如果第三个参数 strict 的值为 TRUE 则 in_array() 函数还会检查 needle 的类型是否和 haystack 中的相同。

if (!in_array($type,[1,2,3],true)) {
    $this->json->setErr(10003, '任务类型非法');
    $this->json->Send();
}

第三个参数是true的时候,很严格。如果type的值是数字1,2,3就匹配成功。如果是字符串1,2,3就会提示失败。这是个小细节。

原文地址:https://www.cnblogs.com/jiqing9006/p/10488037.html