class ufo {
const MP_SIZE_LARGE = 600;
const MP_SIZE_MEDIUM = 400;
const MP_SIZE_SMALL = 250;
const LARGE = 'LARGE';
const MEDIUM = 'MEDIUM';
const SMALL = 'SMALL';
public $mp_size;
public function desired_width() {
switch ( $this->mp_size ) {
case ufo::LARGE : return ufo::MP_SIZE_LARGE;
case ufo::MEDIUM : return ufo::MP_SIZE_MEDIUM;
case ufo::SMALL : return ufo::MP_SIZE_SMALL;
default:
return 0;
}
}
}
So check out the class and function above. What should "desired width" return if mp_size is 0? It makes no sense that the value is anything but 0. Instead, it returns 600. In fact, it will return 400 if I put the "medium" case first. Why would it do that?
The function returns expected values if I put strval() around the mp_size. Can someone explain that? This makes absolutely no sense to me. I can't see how the order of the cases could possibly matter, and I also can't see how any case would be "true" when 0 doesn't equal "LARGE".