PHP5 class constants in switch cases

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?

Well from what the documentation states :
http://us.php.net/manual/en/language.constants.php#language.constants.syntax

Constants may only be defined using the define() function, not by simple assignment;

Well, the error message is actually pretty clear:

Parse error: syntax error, unexpected T_CASE, expecting ‘:’ or ‘{’ on line 32

Looks like you’re missing a {.

switch ($this->getFormat()) {

He is using class constants: http://www.php.net/manual/en/language.oop5.constants.php

Whoops :goof: