GET params çekler için aşağıdaki kodu. Sayfada iki seçer vardır ki filtre tipi ve yaş grubuna göre bir liste.
Ben türü / yaş kombinasyonları test hangi koşullu refactor için bir yol arıyorum. Bunu yazmak için daha açık / kısa yolu var mı?
if ( isset($_REQUEST['type']) || isset($_REQUEST['age']) )
{
// we need to do something
$type = ( $_REQUEST['type'] == 'all' ? false : (int)($_REQUEST['type']) );
$age = ( $_REQUEST['age'] == 'all' ? false : (int)($_REQUEST['age']) );
// test the possible type/age combinations
if ($type && $age)
{
$cats = $type . "," . $age;
}
elseif ($type)
{
$cats = $type;
}
elseif ($age)
{
$cats = $age;
}
else
{
$cats = false;
}
// do stuff with $cats;
}