PHP return Keyword

❮ PHP Keywords

Example

Return a value from a function:

<?php
function add1($x) {
  return $x + 1;
}

echo "5 + 1 is " . add1(5);
?>
Try it Yourself »

Definition and Usage

The return keyword ends a function and, optionally, uses the result of an expression as the return value of the function.

If return is used outside of a function, it stops PHP code in the file from running. If the file was included using include, include_once, require or require_once, the result of the expression is used as the return value of the include statements.


Related Pages

Learn more functions in our PHP Functions Tutorial.


❮ PHP Keywords
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.