Log in / create account | Login with OpenID
DocForge
An Open Wiki For Software Developers

PHP/return

From DocForge

< PHP

return is a PHP construct which immediately ends function execution and optionally sets a value what will be returned to calling code. If no value is set null is returned. Script execution continues with the code following the function call.

Syntax:

return [value];

The returned value may be of any data type, including arrays, objects, and resources.

Example:

function return_nothing() {
    return;
}
 
function return_true() {
    return true;
}
 
$value = return_nothing();  // $value is null
$value = return_true();  // $value is a boolean true

See Also [edit]