简体   繁体   中英

PHP multiple cases for one switch case statement

I'm not to keen on PHP and as such haven't spent much time learning the syntax, I was just wondering if this && operator would be syntactically correct in a switch case, so that I could have multiple cases match one case code block.

case "msg" && "username": 
/* enter the functions here */ 

break;

No, that will not behave correctly. You can however do this:

case "msg":
case "username":
/* enter the functions here */

break;

Updated with Pekka and Marc's comments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM