I would write it like this:
$class_name = '';
if (2 == $variable2)
{
$class_name = 'variable2';
}
elseif ($variable1 > 0)
{
$class_name = 'variable1';
}
echo '<tr class="' , $class_name , '">';
notice that on the equality test I use the constant before the variable.. this is a habit so that if I miss one equal it would result in an error that I would be forced to correct it instead of a "strange" behavior
another thing is that I give the initial value to $class_name and that will be the default one
also I use apostrophes instead of quotation marks because it is faster (because the way you did it php will parse the string for variables)
and the last thing is that I echo multiple string.. that's also faster than concatenating 3 strings (
echo '<tr class="' , $class_name , '">';
and not echo
'<tr class="' . $class_name . '">';
)