I just tried to do this and got a parse error:
class Blah {
const FORMAT_MP3 = 200;
const FORMAT_WMA = 201;
public function fetchUrl(...) {
switch ($this->getFormat())
case self::FORMAT_WMA: <-- line 32
break;
case self::FORMAT_MP3:
break;
default:
// Unrecognised format
}
}
Parse error: syntax error, unexpected T_CASE, expecting ':' or '{' on line 32
Any recommendations on how to use class constants as cases in a switch?