title: get return from echo
body: <p>I'm working with some functions that <code>echo</code> output. But I need their <code>return</code> so I can use them in PHP. </p>
  
  <p><strong>This works</strong> (seemingly without a hitch) but I wonder, is there a better way?</p>
  
  <pre><code>    function getEcho( $function ) {
          $getEcho = '';
          ob_start();
          $function;
          $getEcho = ob_get_clean();
          return $getEcho;
      }
  </code></pre>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>    //some echo function
      function myEcho() {
          echo '1';
      }
  
      //use getEcho to store echo as variable
      $myvar = getEcho(myEcho());      // '1'
  </code></pre>