<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>The Generator class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="closure.bindto.html">Closure::bindTo</a></div> <div class="next" style="text-align: right; float: right;"><a href="generator.current.html">Generator::current</a></div> <div class="up"><a href="reserved.interfaces.html">Predefined Interfaces and Classes</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.generator" class="reference"> <h1 class="title">The Generator class</h1> <div class="partintro"><p class="verinfo">(PHP 5 >= 5.5.0)</p> <div class="section" id="generator.intro"> <h2 class="title">Introduction</h2> <p class="para"> <strong class="classname">Generator</strong> objects are returned from <a href="language.generators.html" class="link">generators</a>. </p> <div class="caution"><strong class="caution">Caution</strong> <p class="para"> <strong class="classname">Generator</strong> objects cannot be instantiated via <a href="language.oop5.basic.html#language.oop5.basic.new" class="link">new</a>. </p> </div> </div> <div class="section" id="generator.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"></div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">Generator</strong> </span> <span class="oointerface">implements <span class="interfacename"><a href="class.iterator.html" class="interfacename">Iterator</a></span> </span> {</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">mixed</span> <span class="methodname"><a href="generator.current.html" class="methodname">current</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">mixed</span> <span class="methodname"><a href="generator.key.html" class="methodname">key</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="generator.next.html" class="methodname">next</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="generator.rewind.html" class="methodname">rewind</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">mixed</span> <span class="methodname"><a href="generator.send.html" class="methodname">send</a></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">mixed</span> <span class="methodname"><a href="generator.throw.html" class="methodname">throw</a></span> ( <span class="methodparam"><span class="type"><a href="class.exception.html" class="type Exception">Exception</a></span> <code class="parameter">$exception</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="generator.valid.html" class="methodname">valid</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="generator.wakeup.html" class="methodname">__wakeup</a></span> ( <span class="methodparam">void</span> )</div> }</div> </div> </div> <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="generator.current.html">Generator::current</a> — Get the yielded value</li><li><a href="generator.key.html">Generator::key</a> — Get the yielded key</li><li><a href="generator.next.html">Generator::next</a> — Resume execution of the generator</li><li><a href="generator.rewind.html">Generator::rewind</a> — Rewind the iterator</li><li><a href="generator.send.html">Generator::send</a> — Send a value to the generator</li><li><a href="generator.throw.html">Generator::throw</a> — Throw an exception into the generator</li><li><a href="generator.valid.html">Generator::valid</a> — Check if the iterator has been closed</li><li><a href="generator.wakeup.html">Generator::__wakeup</a> — Serialize callback</li></ul> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="closure.bindto.html">Closure::bindTo</a></div> <div class="next" style="text-align: right; float: right;"><a href="generator.current.html">Generator::current</a></div> <div class="up"><a href="reserved.interfaces.html">Predefined Interfaces and Classes</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>