default as first option in switch statement?

前端 未结 9 1821
后悔当初
后悔当初 2020-12-01 23:58

I\'ve tested this and it works fine, but it looks... weird... to me. Should I be concerned that this is nonstandard form which will be dropped in a future version of PHP, or

9条回答
  •  臣服心动
    2020-12-02 00:15

    This is how I'd probably do it... it's easy on the eye and keeps the functionality.

    switch($kind)
    {
        case 'kind1': default :
            // Do some stuff for kind 1 here
            break;
        case 'kind2':
            // do some stuff for kind2 here
            break;
        case 'kindn':
            // do some stuff for kindn here
            break;
    }
    

提交回复
热议问题