title: Getting PHP Recoverable fatal error: Object of class Generator could not be converted to string in PHP Iterable
body: <p>I am new in php. Running this php script getting errors:
  It shows this message :- </p>
  
  <blockquote>
    <p>PHP Recoverable fatal error:  Object of class Generator could not be converted to string in  index.php on line 19</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
   class Example {
  
       function bar(): iterable{
           return [1, 2, 3];
       }
  
  
       function gen(): iterable {
           yield 1;
           yield 2;
           yield 3;
       }
  
  }
  $obj=new Example();
  
  print $obj-&gt;gen();
  
  print $obj-&gt;bar();
  </code></pre>