According to your class $result
is by default set:
$result = "";
So you should check your condidtion like this:
if (trim($pr) != '')
Note - trim
is just to make sure there is no whitespace, should work even without it.
Answer as requested in comment.