rungss
05-29-2007, 11:32 PM
define('PROD_CAT_DIGITAL', 1);
define('PROD_CAT_BOOKS', 4);
define('PROD_CAT_STICKERS', 5);
define('PROD_CAT_DIGITAL_OTHERS', 6);
$tmpSubcategoryId = <some value from database>;
switch($tmpSubcategoryId) {
case PROD_CAT_BOOKS :
echo 'Category is Books';exit;
break;
default:
echo 'Category is unknown';exit;
break;
}
In the above code it doesn't work expected, does checking the values with case doesn't allow CONSTANTS defined, or behave unexpectedly if done so?
I don't want o use the values 1, 2,5 inside case I want to define that at the begininig..
define('PROD_CAT_BOOKS', 4);
define('PROD_CAT_STICKERS', 5);
define('PROD_CAT_DIGITAL_OTHERS', 6);
$tmpSubcategoryId = <some value from database>;
switch($tmpSubcategoryId) {
case PROD_CAT_BOOKS :
echo 'Category is Books';exit;
break;
default:
echo 'Category is unknown';exit;
break;
}
In the above code it doesn't work expected, does checking the values with case doesn't allow CONSTANTS defined, or behave unexpectedly if done so?
I don't want o use the values 1, 2,5 inside case I want to define that at the begininig..