Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5657

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>return</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="control-structures.declare.html">declare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.require.html">require</a></div>
 <div class="up"><a href="language.control-structures.html">Control Structures</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.return" class="sect1">
 <h2 class="title">return</h2>
 <p class="verinfo">(PHP 4, PHP 5)</p>
 <p class="simpara">
  If called from within a function, the <em>return</em>
  statement immediately ends execution of the current function, and
  returns its argument as the value of the function
  call. <em>return</em> will also end the execution of
  an  <span class="function"><a href="function.eval.html" class="function">eval()</a></span> statement or script file.
 </p>
 <p class="simpara">
  If called from the global scope, then execution of the current
  script file is ended. If the current script file was
   <span class="function"><a href="function.include.html" class="function">include</a></span>d or  <span class="function"><a href="function.require.html" class="function">require</a></span>d,
  then control is passed back to the calling file. Furthermore, if
  the current script file was  <span class="function"><a href="function.include.html" class="function">include</a></span>d, then
  the value given to <em>return</em> will be returned as
  the value of the  <span class="function"><a href="function.include.html" class="function">include</a></span> call. If
  <em>return</em> is called from within the main script
  file, then script execution ends. If the current script file was
  named by the <a href="ini.core.html#ini.auto-prepend-file" class="link">auto_prepend_file</a> or <a href="ini.core.html#ini.auto-append-file" class="link">auto_append_file</a>
  configuration options in <var class="filename">php.ini</var>,
  then that script file&#039;s execution is ended.
 </p>
 <p class="simpara">For more information, see <a href="functions.returning-values.html" class="link">Returning values</a>.
 </p>
 <p class="para">
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Note that since <em>return</em> is a language
    construct and not a function, the parentheses surrounding its
    arguments are not required. It is common to leave them out, and you
    actually should do so as PHP has less work to do in this case.
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    If no parameter is supplied, then the parentheses must be omitted
    and <strong><code>NULL</code></strong> will be
    returned. Calling <em>return</em> with parentheses but
    with no arguments will result in a parse error.
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    You should <em class="emphasis">never</em> use parentheses around your return
    variable when returning by reference, as this will not work. You can
    only return variables by reference, not the result of a statement. If
    you use <em>return ($a);</em> then you&#039;re not returning a
    variable, but the result of the expression <em>($a)</em>
    (which is, of course, the value of <var class="varname"><var class="varname">$a</var></var>).
    </span>
   </p></blockquote>
 </p>
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="control-structures.declare.html">declare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.require.html">require</a></div>
 <div class="up"><a href="language.control-structures.html">Control Structures</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>