Home  >  Article  >  Backend Development  >  PHP关于switch case话语中多个值匹配一个代码块的代码

PHP关于switch case话语中多个值匹配一个代码块的代码

WBOY
WBOYOriginal
2016-06-13 13:13:491092browse

PHP关于switch case语句中多个值匹配一个代码块的代码

最近一直在想,PHP的switch case语句中多个值匹配一个代码块的代码除了我们常用多个case匹配而不跳出(break)的写法之外,是否还有像VB那样,可以用大括号或者中括号把匹配的值用“,”或者“||”分隔开,怎么试都不行,网上居然还有人乱写说用“||”分开可以,然后被一群人给瞎转载了,真是误人子弟啊!

?

    switch ($cps_sign) {
        case 'yiqifa':
        case 'chengguo':
        case 'roiyiqifa':
        case 'lkt':
        case 'fanli':
        case 'qqfanli':
        case 'weiyi':
        case 'yoyi':
            $sql = "INSERT into sa_cps_list (`uv`,`s_time`,`cps`,`url`) VALUES ('{$uv}',{$timestamp},'{$cps_sign}','{$url}')";
            echo $sql;exit();
            mysql_query($sql);
            break;
        default:
            break;
    }

?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn