代码示例:
switch(true) { case (strlen($foo) > 30): $error = "The value provided is too long."; $valid = false; break; case (!preg_match(‘/^[A-Z0-9]+$/i‘, $foo)): $error = "The value must be alphanumeric."; $valid = false; break; default: $valid = true; break; }
Enjoy it !