title: Return value from anonymous function to parent function
body: <p>I have a setup like this:</p>
  
  <pre><code>function test(){
      function(){
          return "testing!";
      };
      return;
  }
  
  echo test();
  </code></pre>
  
  <p>And I'm trying to get the <code>test()</code> function to return "testing" <em>(in this example)</em> but that doesn't work. What would you advice?</p>
  
  <p><strong>Why are you using an anonymouse function?</strong> 
  I have to use an anonymous function for this because I'm using the HttpClient of ReactPHP, here's a basic example of how that works:</p>
  
  <pre><code>$request = $client-&gt;request('GET', 'https://api.github.com/repos/reactphp/react/commits');
  $request-&gt;on('response', function ($response) {
      $buffer = '';
  
      $response-&gt;on('data', function ($data) use (&amp;$buffer) {
          $buffer .= $data;
          echo ".";
      });
  
      $response-&gt;on('end', function () use (&amp;$buffer) {
          $decoded = json_decode($buffer, true);
          $latest = $decoded[0]['commit'];
          $author = $latest['author']['name'];
          $date = date('F j, Y', strtotime($latest['author']['date']));
  
          echo "\n";
          echo "Latest commit on react was done by {$author} on {$date}\n";
          echo "{$latest['message']}\n";
      });
  });
  $request-&gt;on('end', function ($error, $response) {
      echo $error;
  });
  $request-&gt;end();
  </code></pre>
  
  <p>In the example above they echo the content of the page, but I'd like to return it instead, any help would be <strong>much</strong> appreciated. Thanks!</p>