PHP - Checking return value in an if statement
<p>I have seen programming practices where a string or a boolean can be returned from a function. In such cases, is it recommended to check for empty() and isset() in the if loops, or will just doing a check like if($returnvar) will work or not.</p>

<p>Here's a piece of code I am playing around with. What do you think should be the output and are the checks correct in the if condition?</p>

<p>Thanks,</p>

<pre><code>&lt;?php

function testMe()
{
 try
 {
  $returnText = 'John King Rocks';
  return $returnText;
 }
 catch (Exception $e)
 {
  return false;
 }
}

$str = testMe();
if ($str)
{
  echo $str;
}

?&gt;
</code></pre>
