It seems inefficient to me to write multiple conditions to do the same action,,, for example
if ( (condition_one || (condition_two && condition_three) )
{
// Do this ...
}
elseif ( condition_two && condition_three)
{
// Do same as before ...
}
else
{
// Do that ...
}
Would there be a valid approach to accomplishing this? Where condition_two and condition_three have to be executed together but separately from condition_one...
if ( (condition_one || (condition_two && condition_three) )
{
// Do this ...
}
else
{
// Do that ...
}
In other words,,, is there some way, that I am unaware of, to do this:
if ( ( $a < $b || ( $a <= $b && $c = $d ) )
{
echo 'foo';
}
else
{
echo 'bar';
}
Rather than this:
if ( ( $a < $b )
{
echo 'foo';
}
elseif ( $a <= $b && $c = $d )
{
echo 'foo';
}
else
{
echo 'bar';
}