title: Shorthand if else and anonymous functions
body: <p>I'm trying to use an anonymous function inside a shorthand if else statement.</p>
  
  <pre><code>$str = (true) ? function() { 
      //do something
      return $result;
  }
  :
  function() {
      //do something else
      return $result;
  };
  echo $str;
  </code></pre>
  
  <p>This throws a <code>Object of class Closure could not be converted to string</code> error since the shorthand if/else stores the function in the $str variable.</p>
  
  <p>How can I get the function to execute and then have $str be set to the value that the function return?</p>
  
  <p>I know that there is definitely a much easier and simpler way of doing this. But I'm stubborn and I just want my curiosity satisfied.</p>