Your statement of what to do doesn’t cover the case where the width is exactly 601. Your example code implies that less-than or equal should be used in this case.
In general, you should avoid writing out conditional logic with hard-coded values in it to handle every possible choice, and instead use a data driven design, where the choices are defined in a data structure (an array or a database table), that general purpose logic or an sql query operates on to find the result.
See the following array based solution -
// inputs - $base1width, $drawline
$base1width = 602;
$drawline = true;
// define a data structure that maps the input choices to a result
$map = [];
$map[] = ['width'=>601,'width_comparison'=>'<=','drawline'=>false,'num_handles'=>1];
$map[] = ['width'=>601,'width_comparison'=>'>','drawline'=>false,'num_handles'=>2];
$map[] = ['width'=>601,'width_comparison'=>'<=','drawline'=>true,'num_handles'=>2];
$map[] = ['width'=>601,'width_comparison'=>'>','drawline'=>true,'num_handles'=>4];
// the following code loops until it finds the first true comparison
$found = false;
foreach($map as $element)
{
switch($element['width_comparison'])
{
case '<=':
if($base1width <= $element['width'] && $element['drawline'] == $drawline)
{
$found = true;
break 2; // exit from the foreach loop
}
break;
case '>':
if($base1width > $element['width'] && $element['drawline'] == $drawline)
{
$found = true;
break 2; // exit from the foreach loop
}
break;
}
}
// test the result
if($found)
{
echo 'Result is - '.$element['num_handles'].' handles.';
} else {
echo 'No result found.';
}
You can modify or add choices to this just by changing or adding entries in the $map array. The only time you would edit the program logic is if you add more things that go into deciding what result to match. The switch/case statement can be modified to handle the case where an equal match is a different result.