开发者

Is there a more concise way of writing this simple PHP conditional?

It se开发者_Go百科ems like there would be a shorter way of writing this:

if ($action == 'add' || $action == 'update' || $action == 'delete') {
       // whatever
}

is there?


if (in_array($action, array('add', 'update', 'delete'))) {
    // whatever
}


I prefer this form, since it is easier to maintain:

if(in_array($action, array('add', 'update', 'delete'))) {

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜