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

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

WBOY
Release: 2016-06-13 13:13:49
Original
1107 people have browsed it

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;
    }
Copy after login

?

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template