<!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, PHP 7)</p> <p class="simpara"> <em>return</em> returns program control to the calling module. Execution resumes at the expression following the called module's invocation. </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> also ends 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'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 argument are not required and their use is discouraged. </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> </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>